我可以使用以下URL在我的机器中调用worklight适配器程序。
现在,我想从java程序中调用它。
代码就是这样,
try {
URL myURL = new URL("http://192.168.1.101:10080/AdaptorUI /dev/invoke?adapter=MySQLAdaptor&procedure=procedure1¶meters=[]");
URLConnection myURLConnection = myURL.openConnection();
myURLConnection.connect();
}
catch (MalformedURLException e) {
// new URL() failed
// ...
System.out.println("Inside the MalformedURLException");
}
catch (IOException e) {
// openConnection() failed
// ...
System.out.println("IOException");
}
不知何故上述程序无效。你能帮忙吗?
答案 0 :(得分:0)
首先,您应该从URL中删除/ dev; / dev应仅在开发环境中使用。
其次,我建议查看为此问题提供的解决方案:Java URL doesn't seem to connect, but no exception thrown
来自评论:缺少代码行:
BufferedReader in = new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));