在Oracle中创建java类,该类中创建Socket连接失败

zrf5188 2008-04-25 04:22:40
create or replace and compile java source named clientsocket as
import java.io.*;
import java.net.*;
public class ClientSocket {
static int result=0;
public static void main(String args[]){
ClientSocket sc=new ClientSocket();
sc.sendmessage();

}
public static int sendmessage(){
try{
Socket s = new Socket("192.68.69.96", 8111);

result=1;
}
catch(SecurityException e){
result=2;
System.out.println("securityexception when connecting server!");
}
catch(IOException e){
result=3;
System.out.println("ioexception when connecting server!");
}
return result;
}

}
运行后result=2
...全文
78 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
kokobox 2008-04-25
  • 打赏
  • 举报
回复
不用客气o(∩_∩)o... 解决了就好o(∩_∩)o...
zrf5188 2008-04-25
  • 打赏
  • 举报
回复
Oracle出错提示:
the Permission (java.net.SocketPermission 192.68.69.96:8111 connect,resolve) has not been granted to FOODSAFETYIS. The PL/SQL to grant this is dbms_java.grant_permission( 'FOODSAFETYIS', 'SYS:java.net.SocketPermission', '192.68.69.96:8111', 'connect,resolve' )

问题已解决,谢谢kokobox
kokobox 2008-04-25
  • 打赏
  • 举报
回复
lz 把异常贴出来

用e.printStackTrace();打出来

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧