在oracle触发器中 是否可以直接发起一个Http请求? 如果可以的话 如何发起?谢谢了~~~

解决方案 »

  1.   

    import java.util.*;
    import java.net.*;
    import java.io.*;public class HttpConnection {private static String ServerIP;
    private static String ServerPort;public static void LogIn(String LoginID,String UserName,String UserIP){
    ServerIP = ...;
    ServerPort = ...;
    String SessionID=...;
    String Context = ...;
    SendMessage(Context);
    }private static void SendMessage (String Context) {
    try{
    InetAddress address = InetAddress.getByName(ServerIP);
    Socket socket;
    try{
    socket = new Socket(address,Integer.parseInt(ServerPort));
    }catch (Exception e){
    socket = new Socket(address,80);
    }
    OutputStream os = socket.getOutputStream();
    String text = "GET /"+Context+" HTTP/1.1\r\n";
    text+="Accept image/gif,*/*\r\n";
    text+="Accept-Language: zh-cn\r\n";
    text+="Accept-Encoding: gzip,deflate\r\n";
    text+="User-Agent: Mozilla/4.0 (compatible; MSIE6.0;Windows NT5.0)\r\n";
    text+="HOST:"+ServerIP+"\r\n";
    text+="Connection: Keep-Alive";
    os.write(text.getBytes());
    os.flush();
    os.close();
    socket.close();
    }catch(Exception e){}
    }
    }create or replace procedure login(id varchar2,username varchar2,userip varchar2)
    as LANGUAGE JAVA NAME 'HttpConnection.LogIn(java.lang.String,java.lang.String,java.lang.String)';在trigger中调用login
      

  2.   

    cenlmmx(学海无涯苦作舟)  谢谢了:)