2014-11-02 1 views
2

:있는 ExceptionInInitializerError 내가 JDBC를 사용하여 MS SQL 서버 DB에이 라인에 연결하기 위해 노력하고있어

String connectionUrl = "jdbc:" + url + ";user=dummy;password=dummy;"; 
conn = DriverManager.getConnection(connectionUrl); 

나는이 거대한 벽의 텍스트 에러 받고 있어요 :

Exception in thread "main" java.lang.ExceptionInInitializerError 
    at javax.crypto.JceSecurityManager.<clinit>(JceSecurityManager.java:65) 
    at javax.crypto.Cipher.getConfiguredPermission(Cipher.java:2543) 
    at javax.crypto.Cipher.getMaxAllowedKeyLength(Cipher.java:2567) 
    at sun.security.ssl.CipherSuite$BulkCipher.isAvailable(CipherSuite.java:548) 
    at sun.security.ssl.CipherSuite$BulkCipher.isAvailable(CipherSuite.java:527) 
    at sun.security.ssl.CipherSuite.isAvailable(CipherSuite.java:194) 
    at sun.security.ssl.SSLContextImpl.getApplicableCipherSuiteList(SSLContextImpl.java:350) 
    at sun.security.ssl.SSLContextImpl.getDefaultCipherSuiteList(SSLContextImpl.java:308) 
    at sun.security.ssl.SSLSocketImpl.init(SSLSocketImpl.java:607) 
    at sun.security.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:549) 
    at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:110) 
    at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1606) 
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1323) 
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991) 
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827) 
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012) 
    at java.sql.DriverManager.getConnection(DriverManager.java:664) 
    at java.sql.DriverManager.getConnection(DriverManager.java:270) 
    at BusinessManager.Session.<init>(Session.java:33) 
    at BusinessManager.BusinessManager.getSession(BusinessManager.java:172) 
    at example.Example.ConfigureEnvironment(Example.java:198) 
    at example.Example.main(Example.java:50) 
Caused by: java.lang.SecurityException: Can not initialize cryptographic mechanism 
    at javax.crypto.JceSecurity.<clinit>(JceSecurity.java:89) 
    ... 22 more 
Caused by: java.lang.SecurityException: Cannot locate policy or framework files! 
    at javax.crypto.JceSecurity.setupJurisdictionPolicies(JceSecurity.java:254) 
    at javax.crypto.JceSecurity.access$000(JceSecurity.java:48) 
    at javax.crypto.JceSecurity$1.run(JceSecurity.java:81) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at javax.crypto.JceSecurity.<clinit>(JceSecurity.java:78) 
    ... 22 more 

몇 가지 링크를 따라 서버와 클라이언트가 동일한 JDK (1.8.0_20)를 사용하고 있는지 확인했습니다. "JCE Unlimited Strength Jurisdiction Policy Files"도 다운로드하여 JDK에 포함 시켰습니다. 또한 나는이 link을 따라 갔지만 JDK의 "java.policy"파일에 간섭해야하는지 확신 할 수 없습니다 ...

+0

'url'의 값을 표시 할 수 있습니까? – wero

+0

'url'은'localhost'입니다. – BlueMoon93

+0

그래서'connectionUrl'은''jdbc : localhost; user = dummy; password = dummy; "'입니까? 그건 맞을 수 없다. – wero

답변

1

내 생각에 오류는 SQL에 연결하려고 시도하는 것입니다. SSL 암호화 세션이지만 SQL Server에서 자체 서명 된 인증서를 사용하고 있습니다. Connecting with SSL Encryption 당 : 사용

When the encrypt property is set to true and the trustServerCertificate property is set to true, the Microsoft JDBC Driver for SQL Server will not validate the SQL Server SSL certificate. This is usually required for allowing connections in test environments, such as where the SQL Server instance has only a self signed certificate.

시도 :

String connectionUrl = "jdbc:" + url + ";user=dummy;password=dummy;encrypt=true;trustServerCertificate=true;"; 

또한, 당신의 url 변수 내용이 sqlserver:// 시작해야합니다.

관련 문제