在Oracle的Java存储过程中进行Socket通讯的问题!!!!
我在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;