none
Microsoft JDBC driver 3.0 on JRE 1.6.21(32bit) failed to connect to MSSQL

    Question

  • Our java application sometimes has problems getting new connections.  An Error occur, everyday after restarting the machine.

    • Client OS: Microsoft Windows 2008r2 SE x64 (Our java application and SQL Server are same machine)
    • JDBC Driver:  "Microsoft SQL Server JDBC Driver 3.0" VERSION "3.0.1301.101"
    • Java: JRE 1.6u21(32bit)
    • SQL Server: Microsoft SQL Server Standard Edition (64-bit) 10.50.1617.0
    • Windows task scheduler calls our application every 11PM.

    My Questions are:

    • Did Jdbc Driver try to write any log?  Why JDBC Driver couldn't write any log?
    • What does this error indicate?

    Error message:

    TDSChannel (ConnectionID:1) write failed:Connection reset by peer: socket write error
    com.microsoft.sqlserver.jdbc.SQLServerException logException

    JDBC driver log(Stacktrace):

     (): Connection reset by peer: socket write error
    java.io.IOException: Connection reset by peer: socket write error
        at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.ensureSSLPayload(IOBuffer.java:594)
        at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.readInternal(IOBuffer.java:664)
        at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.read(IOBuffer.java:656)
        at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.readInternal(IOBuffer.java:851)
        at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.read(IOBuffer.java:839)
        at com.sun.net.ssl.internal.ssl.InputRecord.readFully(Unknown Source)
        at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1483)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1042)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:817)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:700)
        at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at jp.co.intec.idms.core.operation.db.DBManager.openImpl(DBManager.java:149)
        at jp.co.intec.idms.core.operation.AbstractOperation.open(AbstractOperation.java:80)
        at jp.co.intec.idms.core.datastorage.impl.DbDataStorageImpl.open(DbDataStorageImpl.java:204)
        at jp.co.intec.idms.core.datastorage.impl.TempDataStorageImpl.open(TempDataStorageImpl.java:153)
        at jp.co.intec.idms.core.framework.manager.impl.AbstractConnector.doSelect(AbstractConnector.java:182)
        at jp.co.intec.idms.core.framework.manager.impl.AbstractConnector.syncData(AbstractConnector.java:121)
        at jp.co.intec.idms.core.framework.manager.impl.FunctionalUnitImpl.doAction(FunctionalUnitImpl.java:100)
        at jp.co.intec.idms.core.framework.manager.impl.FunctionalUnitImpl.execute(FunctionalUnitImpl.java:52)
        at jp.co.intec.idms.core.framework.manager.impl.ScheduleImpl.execute(ScheduleImpl.java:100)
        at jp.co.intec.idms.core.framework.manager.impl.DefaultControl.start(DefaultControl.java:90)
        at jp.co.intec.idms.core.framework.manager.main.YuitoCore.main(YuitoCore.java:149)
    2013/08/28 23:11:32 com.microsoft.sqlserver.jdbc.TDSChannel enableSSL
    INFO: java.security path: C:\Program Files (x86)\Java\jre6\lib\security
    Security providers: [SUN version 1.6, SunRsaSign version 1.5, SunJSSE version 1.6, SunJCE version 1.6, SunJGSS version 1.0, SunSASL version 1.5, XMLDSig version 1.0, SunPCSC version 1.6, SunMSCAPI version 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.RSASignature
    , SunJSSE: KeyManagerFactory.SunX509 -> com.sun.net.ssl.internal.ssl.KeyManagerFactoryImpl$SunX509
    , SunJSSE: KeyManagerFactory.NewSunX509 -> com.sun.net.ssl.internal.ssl.KeyManagerFactoryImpl$X509
    , SunJSSE: TrustManagerFactory.SunX509 -> com.sun.net.ssl.internal.ssl.TrustManagerFactoryImpl$SimpleFactory
    , SunJSSE: TrustManagerFactory.PKIX -> com.sun.net.ssl.internal.ssl.TrustManagerFactoryImpl$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.DefaultSSLContextImpl
    , SunJSSE: KeyStore.PKCS12 -> com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore
    ]
    java.ext.dirs: C:\Program Files (x86)\Java\jre6\lib\ext;C:\Windows\Sun\Java\lib\ext



    • Edited by msmt_ Tuesday, September 10, 2013 11:02 AM
    Friday, September 06, 2013 6:35 AM

All replies

  • Hi msmt_,

    "Connection Reset by Peer" means that SQL Server is terminating the connection prematurely. It can have many causes so I suggest looking at both the SQL Server Profiler Traces and the JDBC Driver Diagnostic Logs and try to determine what was the operation immediately before the connection was terminated.
     
    Here is how to enabled Logging in the JDBC driver:
    http://msdn2.microsoft.com/en-us/library/ms378517.aspx

    An exception occurred during the DBComms.receive method
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/91885a1b-453d-462e-9bac-274fd8b37116/an-exception-occurred-during-the-dbcommsreceive-method


    Allen Li
    TechNet Community Support

    Monday, September 09, 2013 1:47 AM
  • Hi Allen Li,

    Thanks to reply!
    JDBC driver log is already enabled.
    Isn't it enough?

    Current setting is following:
    com.microsoft.sqlserver.jdbc.Connection.level = FINEST
    com.microsoft.sqlserver.jdbc.internals.TDS.Channel.level = FINEST
    com.microsoft.sqlserver.jdbc.internals.SQLServerException.level = FINE
    com.microsoft.sqlserver.jdbc.internals.SQLServerDriver.level = FINE

    JDBC driver log that is in above.

    Do you know what "socket write error" means?
    Did JDBC driver fail establish SSL connection? or fail something else?
    Tuesday, September 10, 2013 11:01 AM
  • Hai, are u able to find a solution, I am using JDBC4.0, and its showing the same SSL problems, I think MICROSOFT HAS SCREWED UP ON THIS.............................BIG TIME MICROSOFT ISSUES SOME BIG UPDATE ON THIS, THOUGH THERE ARE MANY UPDATES IT SEEMS THEY ARE ALL FOR A TIME PASS.
    Sunday, November 24, 2013 3:04 PM