在Oracle的Java存储过程中进行Socket通讯的问题!!!!

musicboy1999 musicboy1999 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我在Oracle写了一个存储过程,其中调用了一个已编译的Java Socket类,向外部的
应用程序Socket Server发送消息。。。类、存储过程均编译通过,执行OK!但Socket
Server 并未显示出连接。

大家看看,代码有何错误??

/************在SQL*Plus中创建java类*******/
CREATE OR REPLACE and compile java source named ClientSocket
as
import java.io.*;
import java.net.*;
public class ClientSocket {
public static void main(String[] args){
ClientSocket sc = new ClientSocket();
sc.sendmessage();
}
public static void sendmessage(){
try{
Socket s = new Socket("localhost", 5000);
OutputStream out = s.getOutputStream();
out.write((new String("client message.")).getBytes());
out.close();
System.out.println("message send success!");
s.close();
}
catch(SecurityException e){
System.out.println("SecurityException when connecting Server!");
}
catch(IOException e){
System.out.println("IOException when connecting Server!");
}
}
}

/**********创建存储过程******************/
CREATE OR REPLACE procedure run_ClientSocket
as language java
name 'ClientSocket.sendmessage()';

/**********执行存储过程******************/
execute run_'ClientSocket;


...全文
评论 3
收藏 已收藏
分享
返回顶部
musicboy1999
基础和管理 17,379 成员 95,111 内容