请告知例外情况

时间:2010-09-19 05:08:28

标签: java database oracle ssl

任何机构都可以告诉我这个异常意味着什么,它令人困惑,因为我尝试了所有可能的方法来改变密钥库的路径..不起作用。

环境:ORACLE数据库服务器,配置SSL

Exception in thread "main" java.sql.SQLException: Io exception: 

java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
 at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
 at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
 at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
 at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
 at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
 at java.sql.DriverManager.getConnection(DriverManager.java:582)
 at java.sql.DriverManager.getConnection(DriverManager.java:154)
 at project1.JDBCSSLTest.getConnection(JDBCSSLTest.java:42)
 at project1.JDBCSSLTest.run(JDBCSSLTest.java:22)
 at project1.JDBCSSLTest.main(JDBCSSLTest.java:49)

我正在使用的java类是。

package project1;

import java.security.Security;

import java.sql.Connection;
import java.sql.SQLException;

import java.sql.*;
import oracle.jdbc.OracleDriver;

public class JDBCSSLTest
{

public JDBCSSLTest()
{
 // must enable this
 Security.addProvider(new oracle.security.pki.OraclePKIProvider());
}

public void run () throws SQLException
{
 Connection conn = getConnection();
 System.out.println("Auto Commit = " + conn.getAutoCommit());
 conn.close();
}

public static Connection getConnection() throws SQLException
{
 String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)" +
              "(HOST=localhost)(PORT=2484))" +
              "(CONNECT_DATA=(SERVICE_NAME=orcl)))";
 java.util.Properties props = new java.util.Properties();

 props.setProperty("user", "system");
 props.setProperty("password", "weblogic");
    props.setProperty("javax.net.ssl.trustStore","C://lib//ewallet.p12");
    props.setProperty("javax.net.ssl.trustStoreType","PKCS12");
    props.setProperty("javax.net.ssl.trustStorePassword","weblogic123");
  props.setProperty("oracle.net.ssl_cipher_suites", "SSL_RSA_EXPORT_WITH_RC4_40_MD5, SSL_RSA_EXPORT_WITH_DES40_CBC_SHA");

 DriverManager.registerDriver(new OracleDriver());
 Connection conn = DriverManager.getConnection(url, props);
 return conn;
}

public static void main(String[] args) throws SQLException
{
 JDBCSSLTest dSTest = new JDBCSSLTest();
 dSTest.run();
 System.out.println("all done..");
}
}

2 个答案:

答案 0 :(得分:1)

来自this Oracle document

“java.sql.SQLException: Io exception: java.lang.RuntimeException:
 Unexpected error: java.security.InvalidAlgorithmParameterException: 
 the trustAnchors parameter must be non-empty”: 
     

如果您使用的是PKCS12   钱包和Oracle的PKI提供程序未正确启用。这个例外   来自Sun(Sun的PKI提供商)的PKCS12实现   这与Oracle钱包不兼容。 Oracle的PKI提供商必须是   如果使用,可以静态或动态地为PKCS12正确启用   PKCS12钱包。

启用PKI提供程序在同一文档的第2.2.4节中描述。​​

答案 1 :(得分:1)

我对此并不熟悉,但是会触发用户代码中的异常信息

   at project1.JDBCSSLTest.getConnection(JDBCSSLTest.java:42)

并且在检索连接时运行时缺少必需的属性

Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

看起来好像你没有配置这个必需的'trustAnchors'属性。