0

我创建了一个 Java 源代码并对其进行了编译,并将其包装在一个带有 jdk+jre 1.8.0._201 的 Oracle 19c 过程中。我正在连接到一个使用 TLS 1.2 和相互身份验证的套件(使用私钥)。我已经使用 dbms_java.grant_permission 设置了 java 权限。

这是java代码:

CREATE OR REPLACE and COMPILE JAVA SOURCE NAMED  "Test" AS


import java.io.*;
import java.sql.*;
import java.net.URL;
import java.security.KeyStore;
import java.security.KeyStore.SecretKeyEntry;
import javax.crypto.SecretKey;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
public class Test{
    public static void test(String[] body,String[] result, String[] response){
        String s=body[0];
        String lenn = Integer.toString(s.length()); 
        result[0]="ok";
        System.setProperty("java.net.preferIPv4Stack" , "true");
        try  {
           String keyPath = "C:\\me\\keystore.jks";
           String keyPass = "123";
           String keyType = "JKS";
           System.setProperty("javax.net.ssl.keyStore", keyPath);
           System.setProperty("javax.net.ssl.keyStorePassword", keyPass);
           System.setProperty("javax.net.ssl.keyStoreType", keyType);
           URL url = new URL("URL"); 
           HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
           con.setRequestMethod("POST");
           con.setDoOutput( true );
           con.connect();
           //----------send body
           OutputStreamWriter writer = new 
                  OutputStreamWriter(con.getOutputStream());
           writer.write(s);
           writer.flush();
           writer.close();
           //--------- reading the response
           BufferedReader in = new BufferedReader(new 
                  InputStreamReader(con.getInputStream()));
           String inputLine;
           StringBuffer buff = new StringBuffer();
           while ((inputLine = in.readLine()) != null) {
                buff.append(inputLine);
           }
           response[0]=buff.toString();
           con.disconnect();
      } catch(Exception ex) {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            result[0]=sw.toString();
      }
   } 
}
/
show errors
/

我尽我所能,但没有运气,我得到了以下错误:

java.net.SocketException: connect failed, 10022
An invalid argument was
supplied.
        at java.net.DualStackPlainSocketImpl.connect0(Native Method)
        at
java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79
)
        at
java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        a
t
java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:2
06)
        at
java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at
java.net.PlainSocketImpl.connect(PlainSocketImpl.java:255)
        at
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at
java.net.Socket.connect(Socket.java:589)
        at
sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:666)
        at
sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
        at
sun.net.NetworkClient.doConnect(NetworkClient.java:180)
        at
sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
        at
sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
        at
sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
        at
sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
        at
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(A
bstractDelegateHttpsURLConnection.java:191)
        at
sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java
:1156)
        at
sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:
1050)
        at
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDe
legateHttpsURLConnection.java:177)
        at
sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl
.java:162)
        at Test.west(Test:27)
PL/SQL procedure successfully completed.

这是我创建 oracle 过程的方式:

CREATE OR REPLACE procedure test (body IN out VARCHAR2,result in OUT VARCHAR2,resp in OUT VARCHAR2)
AS LANGUAGE JAVA
NAME 'Test.test(java.lang.String[],java.lang.String[],java.lang.String[])';

调用过程

calling the procedure:
set serveroutput on
declare
body varchar2(32767);
resp varchar2(32767);
result varchar2(32767);
begin
body:='xml text ..........';
test(body,result,resp);
dbms_output.put_line(result);
dbms_output.put_line(resp);
dbms_output.put_line(length(resp));
end;
/
4

0 回答 0