获取sql server连接异常

but5z9lq  于 2021-07-06  发布在  Java
关注(0)|答案(1)|浏览(320)

在尝试使用jdbc连接到sql server时,我遇到了以下连接异常。
有人能帮忙解决这个问题吗?
我正在使用sqljdbc4.jar文件连接到sql server
代码如下

String dbURL = "jdbc:sqlserver://10.156.54.123;encrypt=false;DatabaseName=PRA;sslProtocol=TLSv1;";
 String user = "username";
 String pass = "password";
 conn = DriverManager.getConnection(dbURL, user, pass);

这是个例外。
2020年11月14日下午8:33:01 com.microsoft.sqlserver.jdbc.tdschannel enablessl信息:java.security path:/usr/java/jdk1.8.0昝-amd64/jre/lib/security security providers:[sun version 1.8,sunrsassign version 1.8,sunec version 1.8,sunjsse version 1.8,sunjce version 1.8,sunjgss version 1.8,sunsasl version 1.8,xmldsig version 1.8,sunpcsc version 1.8]sslcontext provider信息:sun jsse provider(pkcs12,sunx509/pkix key/trust factories,sslv3/tlsv1/tlsv1.1/tlsv1.2/tlsv1.3)sslcontext provider服务:[sunjsse:keypairgenerator.rsa->sun.security.rsa.rsakypairgenerator$旧别名:[1.2.840.113549.1.1,oid.2.840.113549.1.1],sunjsse:signature.sha1withrsa->sun.security.rsa.rsasignature$sha1withrsa别名:[1.2.840.113549.1.1.5,1.3.14.3.2.29,oid.1.2.840.113549.1.1.5]属性:{supportedkeyclasses=java.security.interfaces.rsapublickey | java.security.interfaces.rsaprivatekey},sunjsse:sslcontext.tls->sun.security.ssl.sslcontextimpl$tlscontext别名:[ssl],sunjsse:sslcontext.tlsv1->sun.security.ssl.sslcontextimpl$tls10context别名:[sslv3],sunjsse:signature.md2withrsa->sun.security.rsa.rsasignature$md2withrsa别名:[1.2.840.113549.1.1.2,oid.1.2.840.113549.1.1.2]属性:{supportedkeyclasses=java.security.interfaces.rsapublickey | java.security.interfaces.rsaprivatekey},sunjsse:keyfactory.rsa->sun.security.rsa.rsakeyfactory$旧别名:[1.2.840.113549.1.1,oid.1.2.840.113549.1.1],sunjsse:signature.md5withrsa->sun.security.rsa.rsasignature$md5withrsa别名:[1.2.840.113549.1.4,oid.1.2.840.113549.1.1.4]属性:{supportedkeyclasses=java.security.interfaces.rsapublickey | java.security.interfaces.rsaprivatekey},sunjsse:keystore.pkcs12->sun.security.pkcs12.pkcs12keystore,sunjsse:trustmanagerfactory.sunx509->sun.security.ssl.trustmanagerfactorimpl$simplefactory,sunjsse:keymanagerfactory.sunx509->sun.security.ssl.keymanagerfactoryimpl$sunx509,sunjsse:trustmanagerfactory.pkix->sun.security.ssl.trustmanagerfactorimpl$pkixfactory别名:[sunpkix,x509,x.509],sunjsse:keymanagerfactory.newsunx509->sun.security.ssl.keymanagerfactoryimpl$x509别名:[pkix],sunjsse:sslcontext.default->sun.security.ssl.sslcontextimpl$defaultsslcontext,sunjsse:sslcontext.tlsv1.1->sun.security.ssl.sslcontextimpl$tls11context,sunjsse:signature.md5andsha1withrsa->sun.security.ssl.rsasignature,sunjsse:sslcontext.tlsv1.3->sun.security.ssl.sslcontextimpl$tls13context,sunjsse:sslcontext.tlsv1.2->sun.security.ssl.sslcontextimpl$tls12context]java.ext.dirs:/usr/java/jdk1.8.0旸-amd64/jre/lib/ext:/usr/java/packages/lib/ext com.microsoft.sqlserver.jdbc.sqlserverexception:驱动程序无法使用安全套接字层(ssl)加密建立到sql server的安全连接。错误:“意外重试”。

xtupzzrd

xtupzzrd1#

嘿,你只要按照下面的步骤来解决你的问题issue:---
你只需要:去javafolder:---

1)Find file “java.security” in folder “jre\conf\security”

2)`In this java.security file, find “3DES_EDE_CBC” linked to “jdk.tls.disabledAlgorithms”`

3)Remove it!

    Sample:
    If file "C:\Users\myUser\AppData\jre\conf\security\java.security"

    ORIGINAL:

    jdk.tls.disabledAlgorithms=SSLv3, RC4, DES, MD5withRSA, DH keySize < 1024,
    EC keySize < 224, 3DES_EDE_CBC, anon, NULL

    NEW (after removing “3DES_EDE_CBC”):

    jdk.tls.disabledAlgorithms=SSLv3, RC4, DES, MD5withRSA, DH keySize < 1024,
    EC keySize < 224, anon, NULL

相关问题