java - Unable to connect to MS SQL Server 2008 using a JAR from command prompt but runs successfully in Eclipse -
i trying connect sql server 2008
using sqljdbc4.jar
, connect using eclipse.
but when export code jar , try run using command prompt, error :
d:\eclipse\testdbjar>java -djava.ext.dirs=lib -jar testdb.jar apr 5, 2013 11:17:17 com.microsoft.sqlserver.jdbc.tdschannel enablessl info: java.security path: c:\program files\java\jre6\lib\security security providers: [sun version 1.6, sunrsasign version 1.5, sunjsse version 1. 6, sunjgss version 1.0, sunsasl version 1.5, xmldsig version 1.0, sunpcsc versio n 1.6] sslcontext provider info: sun jsse provider(pkcs12, sunx509 key/trust factories, sslv3, tlsv1) sslcontext provider services: [sunjsse: keyfactory.rsa -> sun.security.rsa.rsakeyfactory aliases: [1.2.840.113549.1.1, oid.1.2.840.113549.1.1] , sunjsse: keypairgenerator.rsa -> sun.security.rsa.rsakeypairgenerator
aliases: [1.2.840.113549.1.1, oid.1.2.840.113549.1.1] , sunjsse: signature.md2withrsa -> sun.security.rsa.rsasignature$md2withrsa
aliases: [1.2.840.113549.1.1.2, oid.1.2.840.113549.1.1.2] , sunjsse: signature.md5withrsa -> sun.security.rsa.rsasignature$md5withrsa
aliases: [1.2.840.113549.1.1.4, oid.1.2.840.113549.1.1.4] , sunjsse: signature.sha1withrsa -> sun.security.rsa.rsasignature$sha1withrsa
aliases: [1.2.840.113549.1.1.5, oid.1.2.840.113549.1.1.5, 1.3.14.3.2.29, oid.1 .3.14.3.2.29] , sunjsse: signature.md5andsha1withrsa -> com.sun.net.ssl.internal.ssl.rsasignat ure , sunjsse: keymanagerfactory.sunx509 -> com.sun.net.ssl.internal.ssl.keymanagerf actoryimpl$sunx509 , sunjsse: keymanagerfactory.newsunx509 -> com.sun.net.ssl.internal.ssl.keymanag erfactoryimpl$x509 , sunjsse: trustmanagerfactory.sunx509 -> com.sun.net.ssl.internal.ssl.trustmana gerfactoryimpl$simplefactory , sunjsse: trustmanagerfactory.pkix -> com.sun.net.ssl.internal.ssl.trustmanager factoryimpl$pkixfactory
aliases: [sunpkix, x509, x.509] , sunjsse: sslcontext.ssl -> com.sun.net.ssl.internal.ssl.sslcontextimpl , sunjsse: sslcontext.sslv3 -> com.sun.net.ssl.internal.ssl.sslcontextimpl , sunjsse: sslcontext.tls -> com.sun.net.ssl.internal.ssl.sslcontextimpl , sunjsse: sslcontext.tlsv1 -> com.sun.net.ssl.internal.ssl.sslcontextimpl , sunjsse: sslcontext.default -> com.sun.net.ssl.internal.ssl.defaultsslcontexti mpl , sunjsse: keystore.pkcs12 -> com.sun.net.ssl.internal.pkcs12.pkcs12keystore ] java.ext.dirs: lib com.microsoft.sqlserver.jdbc.sqlserverexception: driver not establish secure connection sql server using secure sockets layer (ssl) encryption . error: "rsa premaster secret error". clientconnectionid:c0a357b6-e274-41b2-9fd a-7ef89ebdfb7a @ com.microsoft.sqlserver.jdbc.sqlserverconnection.terminate(sqlserverc onnection.java:1667) @ com.microsoft.sqlserver.jdbc.tdschannel.enablessl(iobuffer.java:1668)@ com.microsoft.sqlserver.jdbc.sqlserverconnection.connecthelper(sqlser
verconnection.java:1323) @ com.microsoft.sqlserver.jdbc.sqlserverconnection.login(sqlserverconne ction.java:991) @ com.microsoft.sqlserver.jdbc.sqlserverconnection.connect(sqlservercon nection.java:827) @ com.microsoft.sqlserver.jdbc.sqlserverdriver.connect(sqlserverdriver. java:1012) @ java.sql.drivermanager.getconnection(unknown source) @ java.sql.drivermanager.getconnection(unknown source) @ testdbconnection.main(testdbconnection.java:13) caused by: javax.net.ssl.sslkeyexception: rsa premaster secret error @ com.sun.net.ssl.internal.ssl.rsaclientkeyexchange.(unknown sour ce) @ com.sun.net.ssl.internal.ssl.clienthandshaker.serverhellodone(unknown source) @ com.sun.net.ssl.internal.ssl.clienthandshaker.processmessage(unknown source) @ com.sun.net.ssl.internal.ssl.handshaker.processloop(unknown source) @ com.sun.net.ssl.internal.ssl.handshaker.process_record(unknown source ) @ com.sun.net.ssl.internal.ssl.sslsocketimpl.readrecord(unknown source)
@ com.sun.net.ssl.internal.ssl.sslsocketimpl.performinitialhandshake(un
known source) @ com.sun.net.ssl.internal.ssl.sslsocketimpl.starthandshake(unknown sou rce) @ com.sun.net.ssl.internal.ssl.sslsocketimpl.starthandshake(unknown sou rce) @ com.microsoft.sqlserver.jdbc.tdschannel.enablessl(iobuffer.java:1618)
... 7 more caused by: java.security.nosuchalgorithmexception: suntlsrsapremastersecret keyg enerator not available @ javax.crypto.keygenerator.<init>(dashoa13*..) @ javax.crypto.keygenerator.getinstance(dashoa13*..) @ com.sun.net.ssl.internal.ssl.jssejce.getkeygenerator(unknown source) ... 17 more
i providing external lib folder having sqljdbc4.jar
in , running jar using java -djava.ext.dirs=lib -jar testdb.jar
i have read through various posts didn't work.
exporting runnable
jar after selecting option of copy required libraries next generated jar
solved issue. normal jar, somehow, not able access lib
folder.
Comments
Post a Comment