Welcome to the SQL Server JDBC blog


Unsure of what to specify in the connection URL? Having trouble configuring the driver for Integrated Authentication? Confused about some behavior with the Microsoft SQL Server JDBC driver? Then, this is the blog site for you.


The SQL Server JDBC team maintains this blog.  The team is responsible for all things regarding JDBC with SQL Server.  We hope to use this blog to proactively provide answers to many of the re-occuring issues that we see our customers face.  We will also use this blog to provide some insight into features in planning for future releases.


Hopefully you will find this useful.


SQL Server JDBC team
Disclaimer: This posting is provided “AS IS” with no warranties, and confers no rights


Comments (87)

  1. Kris says:

    Glad to see this. I would like to use JPA (Java Persistence API from Hibernate) with SQL Server Express edition. Wondering if you guys can provide any information with regard to this.

    Thanks.

  2. dpblogs says:

    We are a hibernate ceritified driver. YOu should use SQLServerDialect in the configuration see: http://www.hibernate.org/hib_docs/v3/reference/en/html/session-configuration.html

    Let me know if there is anything specific you want to know.

    Thanks

    Mugunthan

  3. Berik says:

    I have a password protected database. How can I connect to it via JDBC? In what connection parameter I must send database password?

  4. Yesim says:

    Hi,

    Before we can answer your question, we need to know which SQL Server Edition you are using. Could you please clarify?

    Thanks!

    Yesim [MSFT]

  5. steve.lloyd says:

    I’ve been trying to configure Tomcat 6.0 to use the SQL Server 2005 JDBC Driver to access SQL Server 2005 through a jndi provided DataSource.

    I am converting from programmatic creation of a Connection to using a DataSource to obtain a Connection.

    I’m using the following per web application WEB-INFcontext.xml:

    <Context path="/eclipse" docBase="eclipse" debug="5" reloadable="true" crossContext="true">

       <Resource

           name="jdbc/orpsMirror"

           auth="Container"

           type="com.microsoft.sqlserver.jdbc.SQLServerDataSource"

           username="user"

           password="pass"

           driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"

           url="jdbc:sqlserver://PN1236318.lanl.gov"

           validationQuery="select 1"

           maxActive="10"

           maxIdle="2"

       />

    </Context>

    and the following WEB-INFweb.xml fragment

       <resource-ref>

           <description>SQL Server</description>

           <res-ref-name>jdbc/orpsMirror</res-ref-name>

           <res-type>com.microsoft.sqlserver.jdbc.SQLServerDataSource</res-type>

           <res-auth>Container</res-auth>

       </resource-ref>

    When i execute something like the following code,

               ctx = new InitialContext();

               Object object;

               object = ctx.lookup("java:comp/env/jdbc");

    I get the following STDOUT log message

    javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

    Can you tell me how to configure Tomcat to allow servlets and JSP pages to access SQL Server? This has been somewhat frustrating.

    Thanks.

  6. Eric Marquez says:

    Hello. I’m developing my application in Sun Java Studio Creator and Sun AppServer 8.2. I have this application that uploads pdf files to the database. With SQLServer 2000 it works, but now I’m using the same application to upload files to SQLServer 2005 and it doesn’t work. Is there any property or something else that I must set in the database in order to do this? Thanks in advance.

    Eric.

  7. Eric Marquez says:

    Sorry, I forgot to mention in my previous post that I’m using the latest JDBC driver (sqljdbc.jar v1.2.2727).

  8. Hello Steve,

    The issue I believe you are hitting is your Context is not complete.  I’ve seen this done one of two ways:

    1.  Grab the environment first, and then grab the datasource

    // Grab the Environment first

    object = ctx.lookup("java:comp/env");

    // Now grab the DataSource

    DataSource ds = (DataSource)ctx.lookup("jdbc/orpsMirror");

    2. Grab the DataSource from the get go

    // Grab the DataSource with the full path from the Environment

    DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/orpsMirror");

    I believe yours was failing because it was just looking for an element called "jdbc" which didn’t exist.

    Hope that helps!

    Thanks,

    Adam [MSFT]

  9. Correction to the first code segment I posted.  It should be:

    // Grab the Environment first

    Context envCtx = (Context)ctx.lookup("java:comp/env");

    // Now grab the DataSource

    DataSource ds = (DataSource)envCtx.lookup("jdbc/orpsMirror");

  10. tfan@kronos.com says:

    Hi,

      We are evaluating JDBC v1.2 and found out there is different with getBytes Method (SQLServerResultSet) call getBytes Method (SQLServerResultSet)

    this is output when I tried two drivers:

    using JDBC v1.1

    Timestamp from DB is: 2007-10-26 12:45:45.9

    byte array is:

    0 is -45

    1 is -103

    2 is 0

    3 is 0

    4 is -38

    5 is 82

    6 is -46

    7 is 0

    using JDBC v1.2

    Timestamp from DB is: 2007-10-26 12:44:42.04

    0 is 0

    1 is 0

    2 is -103

    3 is -45

    4 is 0

    5 is -46

    6 is 8

    7 is 4

    you can see first 4 elements values have been changed (with different order).  can someone provide more information about this? Thanks.

    –Tony

  11. Amalia says:

    Hola actualice el sqljdbc 1.1 por la vesion 1.2 y al ejecutar cualquier consulta me da este error com.microsoft.sqlserver.jdbc.SQLServerException: La instrucción no devolvió un conjunto de resultados.

    Si me pudieran ayudar con esto… Gracias

  12. Mugunthan says:

    Can you provide a sample that is failing?

    Thx

    ¿Puede usted proporcionar una muestra que falla?

  13. Rohit Gupta says:

    I’m using Tomcat 5.5, J2SDK 1.4 and I want to access my db at MS SQL Server 2000. I’m getting error as

    "Following error/exception occured – java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unsupported method: ResultSet.isAfterLast at"

    Also

    Following error/exception occured – java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unsupported method: ResultSet.setFetchDirection at

    Any help???

  14. Mugunthan says:

    Can you try the SQL 2005 JDBC Driver, this supports SQL 2000 server as well.

  15. Diana says:

    Hi Everyone,

    Does anyone know if it is possible through JDBC connection to have the loginto  SQL server automatically authenticate through AD(Active Directory – windows login, instead of entering a user name and password.) similar to single sign on.

    If possbile, how? Can anyone direct me to any documentations, etc?

    Thanks

  16. Ray says:

    I have the same question as Diana above.  Does anybody have a response for this?   Diana,  were you able to get an answer outside this blog?

  17. Ashish Gupta india says:

    i am having an issue while using JDBC driver to connect to MSSQL2000 server

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3199367&SiteID=1

  18. Jeff says:

    I’m trying to connect with integrated security using the 2005 JDBC driver. Here is the error message:  Error creating JDBC Connection to RLID.

    (Error: This driver is not configured for integrated authentication.)  I’ve installed sqljdbc_auth.dll in my Eclipse folder, and in the windows/system32 folder.  I don’t have any problems connecting with Windows Authentication using SQL Management Studio.  Intermittently, the connection will succeed even after throwing the error message.

  19. Colby says:

    I am trying to  connect Sun Application Server 8 to MS SQL 2005.  I can currently connect to SQL 2000 just fine and I am wondering if there are any differences that need to be taken into account — Class Names, Resource Types, etc.

    thx

  20. Colby says:

    I am trying to  connect Sun Application Server 8 to MS SQL 2005.  I can currently connect to SQL 2000 just fine and I am wondering if there are any differences that need to be taken into account — Class Names, Resource Types, etc.

    thx

    —-

    (Sorry I forgot this) I am currently getting this error when trying to Ping using a connection pool:

    Operation ‘pingConnectionPool’ failed in ‘resources’ Config Mbean. Target exception message: Connection could not be allocated because: Network error IOException: Connection refused: no further information

  21. dpblogs says:

    Hi Colby,

    Which JDBC driver are you currently using to connect to SQL Server 2000?

    If you are already using the SQL Server 2005 JDBC driver then you only need to point the application to SQL Server 2005.

    If you are using a different driver you will need to update the class name.  An simple example would look like:

     Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

     String connectionUrl = "jdbc:sqlserver://localhost;database=AdventureWorks;integratedSecurity=true;"

     Connection con = DriverManager.getConnection(connectionUrl);

    Regarding the exception you are getting, I would recommend that you try to create a standalone application outside of the Sun Application Server 8 to make sure you have the right connection string and application settings to connect to SQL Server 2005.

    You will also want to make sure SQL Server 2005 is properly configured to listen to remote TCP connections.  The typical TCP port that SQL Server 2005 listens on is 1433.  Make sure that the Windows OS firewall on SQL Server 2005 machine is not blocking the TCP port.

    If SQL Server 2005 is installed as a named instance and you are specifying the instance name on the connection string, please make sure the SQLBrowser service is running on the SQL Server 2005 machine and Windows firewall is not blocking UDP 1434.

    HTH,

    Jimmy Wu

  22. roger b says:

    I cannot access SQL Server 2K5 through eclipse or through the command line using sqlcmd or osql. I keep getting connection refused. I’m on Vista Ultimate working locally. Management Studio gets through perfectly of course because it is Microsoft technology made to work perfectly with Microsoft technology: seamlessly, flawlessly and magically. Everything else (non-Microsoft technology)takes forty-seven hours of configuration and hacking.

  23. Mugunthan Mugundan -MSFT says:

    Can you say what error you are seeing? Also, have tried the steps provided by Jimmy above.

  24. roger b says:

    FROM T-SQL:

    C:UsersRoger Blackmar>osql -U jboss

    Password:

    [SQL Native Client]Named Pipes Provider: Could not open a connection to SQL

    Server [2].

    [SQL Native Client]Login timeout expired

    [SQL Native Client]An error has occurred while establishing a connection to

    the server. When connecting to SQL Server 2005, this failure may be caused by

    the fact that under the default settings SQL Server does not allow remote

    connections.

  25. roger b says:

    FROM Eclipse:

    com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host  has failed. java.net.ConnectException: Connection refused: connect

    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)

    at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.createConnection(JDBCConnection.java:89)

    at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:104)

    at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:53)

    at org.eclipse.datatools.enablement.msft.internal.sqlserver.connection.JDBCSQLServerConnectionFactory.createConnection(JDBCSQLServerConnectionFactory.java:27)

    at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:83)

    at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:355)

    at org.eclipse.datatools.connectivity.ui.PingJob.createTestConnection(PingJob.java:76)

    at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:59)

    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

  26. roger b says:

    It is not getting to the authentication handshake it is refusing the connection, outright. Management Studio connects immediately without a problem.

  27. dpblogs says:

    Hi Roger,

    You mentioned that you are working locally, is SQL Server configured with TCP enabled?

    For security reasons, by default SQL Server does not enable remote TCP/IP or Named Pipe connection support when initially installed.  This may explain why both Eclipse and OSQL can not connect to SQL Server, while the Management Studio application can.

    Please double check the configuration of SQL Server and also please post the connection URL you are using to connect to SQL Server.

    HTH,

    Jimmy

  28. roger b says:

    Thank you for responding. I resolved the issue by un/reinstalling SQL Server 2005.

    I noticed when reinstalling that there are some IIS 7 components on Vista (same for Server 2008) that you have to manually install through "Turn Windows features on or off". Here is the info for that:(http://learn.iis.net/page.aspx/28/installing-iis-70-on-windows-vista)

    It is working perfectly now in Eclipse.

  29. raj says:

    if any one know about this thing that windows authentication is possible using hibernate for mssql 2005 please give me the information how i will change my hibernate config file i used jtds

    hibernate.cfg file

    <?xml version=’1.0′ encoding=’utf-8′?>

    <!DOCTYPE hibernate-configuration PUBLIC

    "-//Hibernate/Hibernate Configuration DTD//EN"

    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;

    <hibernate-configuration>

    <session-factory name="java:comp/env/hibernate/SessionFactory">

         <property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>

         <property name="hibernate.connection.url">jdbc:jtds:sqlserver://192.168.11.22:1433;databaseName=eventsdb;integrated security=true</property>

         <property name="hibernate.connection.username"></property>

         <property name="hibernate.connection.password"></property>

         <property name="hibernate.connection.pool_size">10</property>

         <property name="connection.autocommit">false</property>

         <property name="show_sql">true</property>

         <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>

          <mapping resource="esq/connector/dataobjects/user.hbm.xml"/>

    </session-factory>

    </hibernate-configuration>

    and i copy all the jar file jtds.jar and native jar or ntlmauth.dll file in system32 or i have given the path in enviroment variable also..i have done all the thing carefully but still

    i am getting error

    "Login failed for user ”. The user is not associated with a trusted SQL Server connection."

  30. raj says:

    if u got any solution plz reply me my id

    EMAIL ME:-raj1112@oneindia.in

  31. Hadi says:

    I use JSQLConnection to connect to sqlserver2000 with this code:

    ————————————————–

    String connectionURL;

    connectionURL = "jdbc:JSQLConnect://COMPUTER1/database=ee/user=hadi/password=hadi";

    Class.forName("com.jnetdirect.jsql.JSQLDriver");

    Connection connection = DriverManager.getConnection(connectionURL);

    —————————————————–

    but i recieved an exeption:

    **********************************************

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    org.apache.jasper.JasperException: Exception in JSP: /ExampleJSP.jsp:73

    70:

    71: // Make the DBMS connection

    72:

    73: Connection connection = DriverManager.getConnection(connectionURL);

    74:

    75: // Make the statement

    76:

    root cause

    javax.servlet.ServletException: com.jnetdirect.jsql.JSQLException: Failed Logon:com.jnetdirect.jsql.JSQLException: TCP/IP connection failed to host:COMPUTER1 java.net.ConnectException: Connection refused: connect url:jdbc:JSQLConnect://COMPUTER1/database=ee/user=hadi/password=hadi

    *****************************************************

    if my username or password or servername is incorrect how can i find them in my data base.

    I use tomcat5.5

  32. dpblogs says:

    Hi Hadi,

    Sounds like you have a generic TCP connection failure issue.  Please take a look at the following blog posting (http://blogs.msdn.com/sql_protocols/archive/2007/07/19/tcp-provider-no-connection-could-be-made-because-the-target-machine-actively-refused-it.aspx).  The concept applies to both SQL Server 2000 and SQL Server 2005.

    We are not experienced with the JSQLConnection driver you are using so I recommend that you ask the appropriate community for additional help.

    Regarding looking up the user and password information, I would recommend asking the DBA who created the database and user.

    Regards,

    Jimmy Wu

  33. Ayojava says:

    pls i just came across this site and I am trying to connect to sql server 2k5 developer edition from cold fusion and i kep having this error

    Connection verification failed for data source: AdventureWorks

    com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user ‘ColdFusionLogin’. The user is not associated with a trusted SQL Server connection.

    The root cause was that: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user ‘ColdFusionLogin’. The user is not associated with a trusted SQL Server connection.

  34. Ayojava says:

    Also while trying to connect to sql server 2k5 from eclipse, i had almost the same error

    om.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user ‘EclipseLogin’. The user is not associated with a trusted SQL Server connection.

    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)

    at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(Unknown Source)

    at com.microsoft.sqlserver.jdbc.TDSParser.parse(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(Unknown Source)

    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnectionInternal(Unknown Source)

    at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnection(Unknown Source)

    at ayoDB.connectDS.main(connectDS.java:23)

    I have already configured a logn id on the server for EclipseLogin using sqlserverauthentication mode and added the jar file to the classpath on eclipse

    any ideas on what to do?

  35. dpblogs says:

    Hi Ayojava,

    The scenario in your first posting, did you verify that the AdventureWorks database is installed on the SQL Server instance you are trying to connect to?

    The scenario in your second posting, please verify that the SQL Server instance you are trying to connect to supports SQL Server user credentials.  One way to verify is to use the SQL Server Management Studio application that comes with SQL Server to see if that works with the same user credentials.  You can also use Management Studio to manage the security configuration of SQL Server.

    If you would like to use SQL Server user credentials, please make sure SQL Server is configured correctly and the "integratedSecurity" property is set to ‘false’ or left as default of ‘false’.

    HTH,

    Jimmy

  36. John says:

    I can successfully use the integrated security feature to connect to my MSSQL 2005 database via a generic class, but if i attempt to use the same connection code the connection fails.

    When running the generic class it passes in the user credentials(the ones I pass into the function) just fine by when I attempt to use the same code in Tomcat it tries to use the Account on the server that running tomcat. Is there any way to force the jdbc driver to use the credentials supplied instead of the servers credentials.

  37. Mugunthan Mugundan - MSFT says:

    There is no way currently in the driver to provide Windows credentials to authenticate the user to SQL Server. Is not possible for you to run the Tomcat instance under a Windows user who has access to SQLServer?

  38. John says:

    Thank you for the quick response

    That would be possible but that makes things odd on a security standpoint. I will give you my scenario. I am a software developer in an organization large enough that I do not have to manage the Tomcat Server or MSSQL Server. The DBAs are asking that we use AD authentication instead of the SQL authentication to access the SQL server.To make this happen I need to use the integerated security feature of the JDBC driver. This works but leads to this issue.  The Tomcat Instance would need to be able to run multiple application all of which would need to use the MSSQL database. Security would not want us to use the same service account to access all the databases; which, if we ran the tomcat instance as the ad user with the ability to connect to mssql it would use the same ad user for all connections.

    Thanks for pointing this out to me. Is there any MS documentation on not being able to provide the windows credentials so I can show my server admins / security / manager.

    Thanks again.

  39. Sudeep says:

    Hi,

    My application used JDBC driver to validate the MS SQL server login.

    ->Currently it uses SQL Server Authentication

    ->I wanted to have my applicataion use Windows Authentication. Hence, added IntegratedSecurity=true to the connection URL.

    ->But DriverManager.getConnection(args[1],pro) errors like this

    [MyApplication][SQLServer JDBC Driver][SQLServer]Login failed for user'(null)’. Reason: Not associated with a trusted SQL Server connection.

    Thanks in advance

    Sudeep.

  40. Carlos says:

    Greetings,

    How to test whether my sql std 2005 server can be connected thru SSL? Every connection is working but connecting thru jdbc fails with

    "Connection string: jdbc:sqlserver://serverbameuser/pwd.

    com.microsoft.sqlserver.jdbc.sqlserverexception

    driver could not establish a secure connection to sql server using ssl.

    TDS proto stream is not valid.

    JDBC 1.2 installed.

    TIA

    Carlos

  41. John says:

    Sudeep your issue may be that the computer/server that your are running the jdbc application on and the computer/server that the MSSQL server is on are on different domains. I ran into the same issue when the client and server were not on the same server.

  42. John says:

    Sorry "I ran into the same issue when the client and server were not on the same DOMAIN"

  43. schubash says:

    Hello.  I’m running SQL Server 2005 and have a named instance.  I have enabled TCP/IP for the instance, and in IPall it lists a dynamic port of 1522.  That’s fine, but I don’t know what to list for the host.  Username and password are separate properies.  My script for the connection is:

    <property name="url" value="jdbc:sqlserver://Localhost:1522;databaseName=TestDB;"/>

    Instead of Localhost, do I enable IP1 in Confirguration Manager and use the IP Address from that?  Do I use the computer name?  Instance name?  I’m just not sure how to define the host.

    Thanks very much,

    schubash

  44. sudhu says:

    hi everyone,

    Can i Use database as a Microsoft Access in hernate.

    if any body know please help me what that approch

    Thnaks

    sud

  45. Jack says:

    I saw that there is a way to embed a failover address into a connection string as shown below:

    "Data Source=SQLAINST1;Failover Partner=SQLBINST1;Initial Catalog=DBMTest;Integrated Security=True"

    Can I do this for a connection from an application running in a Java environment under Tomcat? (Please say yes!!!)

  46. Mark says:

    I am trying to connect eclipse (MyEclipse) to sqlserver 2008.

    Where can I get the connection URL information?

    Thanks

  47. dpblogs says:

    Hey Mark,

    We have a documentation that should help you with this:

    http://msdn.microsoft.com/en-us/library/ms378672.aspx

    –Tres London [SQL Server]

  48. Help says:

    Hi,

    I am using Pentaho right now installed to a local computer and would want to create a data source that connects to a remote MS SQL server but I can’t. I always get this error:

    "Connection attempt failed: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Login failed for user ‘admin’. "

    I am using the following:

    driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"

    url="jdbc:sqlserver://s02-db01;databaseName=scorecard"

    Admin user is already an administrator both in the local computer and in the server.

    I am not an expert in java so I am not sure on how to resolve this. Please help.

    Thanks for all the help.

  49. harry says:

    Hi,

    I am using Pentaho right now installed to a local computer and would want to create a data source that connects to a remote MS SQL server but I can’t. I always get this error:

    "Connection attempt failed: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Login failed for user ‘admin’. "

    I am using the following:

    driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"

    url="jdbc:sqlserver://s02-db01;databaseName=scorecard"

    Admin user is already an administrator both in the local computer and in the server.

    I am not an expert in java so I am not sure on how to resolve this. Please help.

    Thanks for all the help.

  50. harry says:

    Hi,

    I am using Pentaho right now installed to a local computer and would want to create a data source that connects to a remote MS SQL server but I can’t. I always get this error:

    "Connection attempt failed: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Login failed for user ‘admin’. "

    I am using the following:

    driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"

    url="jdbc:sqlserver://s02-db01;databaseName=scorecard"

    Admin user is already an administrator both in the local computer and in the server.

    I am not an expert in java so I am not sure on how to resolve this. Please help.

    Thanks for all the help.

  51. Mugunthan Mugundan [MSFT] says:

    Is the admin user the same user in the remote machine and the local machine? Have you tried using our 2005 driver?

  52. Harry says:

    Yep. they’re the same user. I haven’t tried the 2005 driver. The MS SQL Server I am connecting to is 2000 SP3.

    I’m guessing the problem could be in the security network – it might be blocking my connection but I don’t know how to check this further. =(

  53. dpblogs says:

    Hey Harry,

    Connectivity issues can be a tough nut to crack. However, if you’d just like to verify whether you’re even getting through to your server that should be pretty easy. Just download and install (on your server) our free Netmond Parser:

    http://www.microsoft.com/downloads/details.aspx?familyid=f4db40af-1e08-4a21-a26b-ec2f4dc4190d&displaylang=en

    The protocol SQL Server uses to send data across the wire is TDS. By default Netmon uses a stub parser that won’t reveal any information about TDS. However, it does have a fully functioning TDS parser included, you just have to enable.

    So, have the parser listen for traffic and then initiate your client request. If you see that request come through then you know that your request are at least hitting the server. It could still mean you’re having connectivity problems, they just might lie on your server. In any event, a good place to read about troubleshooting connectivity:

    http://blogs.msdn.com/sql_protocols/archive/2008/04/30/steps-to-troubleshoot-connectivity-issues.aspx

    If you need real support I would recommend you open up a CSS case:

    http://support.microsoft.com/ph/2852

    You could also try and apply SP4 and see if that makes a difference.

  54. Harry says:

    it took me ages to resolve this!

    but glad i did. my SQL Server 2000 authentication mode is set to Windows Authentication mode. JDBC Driver does not support Windows NT authentication so instead, I set authentication mode to Mixed Mode and used the sa account.

  55. manka06 says:

    Hi,

    i’m using JDBC to connect to SQL Server 2005 locally using integrated security. it’s getting failed with the following error code

    Error: 17806, Severity: 20, State: 2.

    Logon       SSPI handshake failed with error code 0x8009030c while establishing a connection with integrated security; the connection has been closed. [CLIENT: 127.0.0.1]

    Logon       Error: 18452, Severity: 14, State: 1.

    Logon       Login failed for user ”. The user is not associated with a trusted SQL Server connection. [CLIENT: 127.0.0.1]

    But i’m able to coneect successfully using 127.0.0.1. the connection is failing only when i give localhost.

    Connection URL:

    jdbc:sqlserver://LOCALHOST:1433;DatabaseName=master;integratedSecurity=true

  56. Mugunthan Mugundan- MSFT says:

    We need little more information on this, this blog post can help you in determining the root cause of this issue

    http://blogs.msdn.com/sql_protocols/archive/2006/02/21/536201.aspx

  57. freddy says:

    mi consulta es la siguiente:

    estoy utilizando el jdbc 1.2 para sql server 2005, junto con JPA de toplink con procedimientos almacenados

    pero me da la siguiente excepcion:

    Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: La instrucción no devolvió un conjunto de resultados.

    esta excepcion solo me da en procedimientos que utilizan como parametros los tipo de datos fecha.

    alguien sabe cual puede ser mi falla?. muchas gracias

  58. aelalaily says:

    Hi, I’m trying to make a java application that connects to an SQL database (2008 Express).

    [code] Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    con = DriverManager.getConnection("jdbc:odbc:OnlineTutorials");

    [/code]

    This returns this error:

    [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

    What’s wrong?

    Thanks!

  59. Mugunthan Mugundan- MSFT says:

    Did you make sure that the onlineTutorials datasource is registered via the odbc administrator. Also, the preferred way to access sqlserver is via our driver not the jdbc odbc bridge.

    http://msdn.microsoft.com/en-us/library/ms378526.aspx

  60. Seshasai says:

    Hi

    I am trying to connect to SQL2008 express edition server from our application and it works fine when I used sqljdbc.jar and jre1.5. But when I used JRE1.6 and sqljdbc4.jar or sqljdbc.jar, I am getting the following error. I have used out of the box configuration and SSL is not enabled

    ===

    com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "SQL Server returned an incomplete response. The connection has been closed."."

    ==

    Here are the details:

    Driver class: com.microsoft.sqlserver.jdbc.SQLServerDriver

    URL:

    jdbc:sqlserver://localhost:1433;databaseName=master;

    I am able to connect to the same server instance using jTDS driver using jre1.6 and it works fine. So, it seems like some issue with combincation of jdbc2.0 driver and JRE1.6. I have tried to google, but could not find a solution. Any pointers on how to resolve this.

    Thank you in advance.

  61. Indranil says:

    I am getting Error – com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "SQL Server returned an incomplete response. The connection has been closed."

    when trying to use the Microsoft SQL Server JDBC Driver 2.0 or 3.0 with JRE 1.6.0. I am using sqljdbc4.jar with JRE 1.6.0. Connection to the same database works fine when using JRE 1.5.0 and sqljdbc.jar. Any clues?

  62. dpblogs says:

    Hi Indranil and Seshasai,

    Assuming that the only thing you change is the JRE and the driver JAR being used, if you are able to connect with one JRE, but not the other, that usually points to some problem with the JRE installation.

    What JRE vendor and version are you using?  Check the output from:

    System.out.println(System.getProperty("java.version"));

    System.out.println(System.getProperty("java.vendor"));

    If you have multiple JRE’s installed, verify that you are using the one that you intend to by checking its installation directory.  Check the output from:

    System.out.println(System.getProperty("java.home"));

    In the 1.6.0 JRE installation, look for the lib/security/java.security file and compare it to the same file from the working 1.5.0 JRE installation.  What are the differences between the files?

    Regards,

    –David Olix [SQL Server]

  63. Warwick says:

    Hello using a esri portal application that is causing me the following error message:

    "Cannot create JDBC driver of class ‘com.microsoft.sqlserver.jdbc.SQLServerDriver’ for connect URL ‘jbdc:sqlserver://BMH9K1SSQLEXPRESS:1433;databaseName=geoportal931’ "

    Operating system XP, tomcat6 with SQLEXPRESS 2005. With the latest sqljdbc.jar ver2 put into C:Program FilesApache Software FoundationTomcat 6.0confcatalinalib.

    The log files are telling me there is a issue with JDBC. See below:

    "Caused by: java.sql.SQLException: No suitable driver

    at java.sql.DriverManager.getDriver(Unknown Source)

    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1143)

    … 37 more"

    08/04/2010 8:54:27 AM com.esri.gpt.framework.sql.DatabaseReference testConnection

    SEVERE: Connection test failed.

    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class ‘com.microsoft.sqlserver.jdbc.SQLServerDriver’ for connect URL ‘jbdc:sqlserver://BMH9K1SSQLEXPRESS:1433;databaseName=geoportal931’

    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1150)

    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)

    at com.esri.gpt.framework.sql.DatabaseReference.openJndiConnection(DatabaseReference.java:269)

    at com.esri.gpt.framework.sql.DatabaseReference.openConnection(DatabaseReference.java:223)

    at com.esri.gpt.framework.sql.DatabaseReference.testConnection(DatabaseReference.java:303)

    at com.esri.gpt.framework.sql.DatabaseReferences.add(DatabaseReferences.java:79)

    at com.esri.gpt.framework.context.ApplicationConfigurationLoader.loadDatabase(ApplicationConfigurationLoader.java:374)

    at com.esri.gpt.framework.context.ApplicationConfigurationLoader.load(ApplicationConfigurationLoader.java:116)

    at com.esri.gpt.framework.context.ApplicationContext.loadConfiguration(ApplicationContext.java:71)

    at com.esri.gpt.framework.context.ApplicationContext.getInstance(ApplicationContext.java:57)

    at com.esri.gpt.framework.context.InitializationServlet.init(InitializationServlet.java:50)

    at javax.servlet.GenericServlet.init(GenericServlet.java:212)

    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)

    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)

    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4042)

    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4348)

    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)

    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)

    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)

    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)

    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)

    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)

    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)

    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)

    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)

    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)

    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)

    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)

    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)

    at org.apache.catalina.core.StandardService.start(StandardService.java:516)

    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)

    at org.apache.catalina.startup.Catalina.start(Catalina.java:566)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

    at java.lang.reflect.Method.invoke(Unknown Source)

    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)

    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

    Caused by: java.sql.SQLException: No suitable driver

    at java.sql.DriverManager.getDriver(Unknown Source)

    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1143)

    … 37 more

    The script to make the connection is in a XML which must call java in the application somehow. The XML is below.

    Would anyone happen to notice some syntax errors?

    geoportal.xml that calls web application..

    <Context docBase="geoportal" path="/geoportal" debug="0" reloadable="true" crossContext="true">

             <Resource name="jdbc/gpt" auth="Container" type="javax.sql.DataSource"

                    driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"

                    url="jbdc:sqlserver://BMH9K1SSQLEXPRESS:1433;databaseName=geoportal931"

    username="geoportal931"

    password="geoportal931pwd"

                    maxActive="20"

                    maxIdle="10"

                    maxWait="-1" />

            </Context>

    Thanks in advance

  64. amisaify says:

    Thank you for using Microsoft SQL Server JDBC driver. This kind of question is best suited for our Data Access Forum (http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/threads) where various team members as well users can reply or if you would like to get help from our CSS then you can contact them at: http://support.microsoft.com/select/?LN=en-us&target=assistance&x=5&y=9

    Thanks

    Amina

  65. Reetam says:

    I am getting the following error while connecting to ms sql server 2005. i am using eclipse ide. can u provide me with detailed steps about how to connect to mssql server 2005 in a java project.

    java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver

    at java.net.URLClassLoader$1.run(Unknown Source)

    at java.security.AccessController.doPrivileged(Native Method)

    at java.net.URLClassLoader.findClass(Unknown Source)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    at java.lang.Class.forName0(Native Method)

    at java.lang.Class.forName(Unknown Source)

    at Connect.getConnection(Connect.java:24)

    at Connect.displayDbProperties(Connect.java:42)

    at Connect.main(Connect.java:78)

    Error Trace in getConnection() : com.microsoft.jdbc.sqlserver.SQLServerDriver

    Error: No active Connection

  66. Srinivas.k says:

    HI, when i connect ms sql2005 with sun application server i'm getting the error as

     " Operation 'pingConnectionPool' failed in 'resources' Config Mbean. Target exception message: Connection could not be allocated because: The TCP/IP connection to the host PC, port 1433 has failed. Error: Connection refused: no further information. Please verify the connection properties and check that a SQL Server instance is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port."

  67. Sameep says:

    Hi, when i am trying to connect eclipse with SQL Server 2005, i am getting following Error

    java.sql.SQLException: No suitable driver found for com.microsoft.sqlserver.jdbc.SQLServerDriver

    in Class.forName syntax.. any help will be great..

  68. Tanushree says:

    hi,

    i am coding in eclipse to access a database on the sql server. i have used the jdbc plugin -sqljdbc_3.0 and sql server 2008 R2. i am not able to get the connection right. it saya that there was a communication error:

    SQL Exception: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

    can anyone please help me out?

  69. Hi there,

    Are there any known issues when using jdbc drivers to connect to 64 bit Windows 2008 R2 / SQL Server 2008 R2 failover clusters?

  70. Hi

    I am using  JDBC 4 in Eclipse with MS SQL Server express 2008. I am getting this error in Eclipse, It is strange since I don't get any error when I use Netbeans. it would be great to have your hints and helps.

    com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset ClientConnectionId:793c3c64-0b9a-4f44-a4fc-1a75f007a911

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1686)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1673)

    at com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:1743)

    at com.microsoft.sqlserver.jdbc.TDSReader.readPacket(IOBuffer.java:4716)

    at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:6021)

    at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:5973)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2907)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2242)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2228)

    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5574)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1734)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1355)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1022)

    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:858)

    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)

    at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.createConnection(JDBCConnection.java:214)

    at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:105)

    at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:54)

    at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.open(JDBCConnection.java:73)

    at org.eclipse.datatools.enablement.msft.internal.sqlserver.connection.JDBCSQLServerConnectionFactory.createConnection(JDBCSQLServerConnectionFactory.java:27)

    at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:83)

    at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:359)

    at org.eclipse.datatools.connectivity.ui.PingJob.createTestConnection(PingJob.java:76)

    at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:59)

    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

    Best Regards,

    Shahrooz

  71. dpblogs says:

    @Shahrooz Sabet

    Can you post your question on the Data access forums so they will reach a wider audience?

    social.msdn.microsoft.com/…/threads

  72. Anyone know how to trace a hanging jdbc connection within Eclipse 3.7.1 (Indigo) using jboss tools 3.3.0 M4 using sqljdbc4? Other jdbc URL's work (eg. IFMX).

    TIA,

    Henry

  73. dpblogs says:

    @freemarket (Henry)

    Try posting your question on the forums to reach a broader audience.

    social.msdn.microsoft.com/…/threads

  74. Basit says:

    Kindly check this link for my question

    stackoverflow.com/…/getting-connection-reset-by-peer-exception-toplink.

    The problem is why i am getting this only for first time and then again things starts work normally. No Reset peer exception after second time.

    Thanks

  75. awanish kumar says:

    Hi friends

       I M Getting Error while creating the connection with Microsoft Sql server 2008 R2. In Place of Driver Jar ,i useing " jtds-1.2.4.jar " but i can't able to create connection

    Error is  = Connection can not be created with the metadata using the given metadata properties

    Please help me

  76. jhonn says:

    necesito conector jdbc para sql server 2005 de eclipse

  77. Gene says:

    I am trying to install Informatica 9.5.1 on a personal Win7 machine where I have pre-installed SQLExpress.  I am at a stage of the install where it ttys to connect to my sql server and cannot because it cannot connect.  My investigation has lead me to a great tool (JDBCTest tool at community.informatica.com/…/jdbctest).  This tool allows one to check the viability of a connection to various vendor databases (sqlserver, oracle…) and if failed connection gives reason.  Well, I tried many variants but all came back with "getConnection() Failed:

    Message: No suitable driver found for jdbc:informatica:sqlserver://localhost;Instance=SQLEXPRESS;DatabaseName=INFA_REPO

    Vendor: 0

    State:  0800"

    So, my conclusion…since my SQLExpress is working just fine is that it has something to do with the sqljdbc…jar but I really don't understand enough in this area to take next steps…any guidance would be appreciated.

  78. prawinlives says:

    Hello Team,

    What JDBC drivers version can be used  for MS SQL server 7 ?

    Also please share the download link for the same.

    Regards

    Praveen

  79. Dharamvir says:

    How can I connect to JDBC data source in SSIS

  80. ROELOF JOHANNES WESTHOF says:

    I really want to know what my jdbc mysql url is?

  81. Dhvani says:

    I am getting Error – com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "SQL Server returned an incomplete response. The connection has been closed."

    I am using Java 1.7 trying to connect to SQL Server 2012. Any thoughts?

  82. Ricky says:

    Hi

    How do we solve this issue "com.microsoft.sqlserver.jdbc.SQLServerException: Socket closed"

                   at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1668)

                   at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1655)

                   at com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:1789)

                   at com.microsoft.sqlserver.jdbc.TDSReader.readPacket(IOBuffer.java:4838)

                   at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:6150)

                   at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:402)

                   at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350)

                   at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)

                   at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1716)

                   at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)

                   at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)

  83. Oleg says:

    Hi,

    My server calls sometimes the MSSQL JDBC CallableStatement.execute() that works with a previously connected connection. Everything is ok while the connection is alive. But if the connection is disconnected somehow (e.g. somebody turn SQL server down) the execute() call throws SQLException. I need to differ between 'connection was dropped' error and any other JDBC error (like table I'm trying to use doesn't exist). Since if I hit the connection error – I need to reconnect. And in any other case I need just to give error message to the user.

    SQLException.getSQLState() and getErrorCode() always return 0 both.

    Thanks

    Oleg

  84. Mike says:

    I am getting the error below on the node that was patched: GDR 4042 for SQL Server 2008 R2 (KB3045313) (64-bit) for 1 application, others are working ok. Note: there are many SQL Servers running in the cluster node, only 1 having an issue.

    [2015-11-10 16:41:45.08] ERROR 000310100002 UTIL.FRAME_JDBC.ERR_ConnectionFactory_create [ConnectionFactory].create()

    [2015-11-10 16:41:45.08] ERROR [1447191705080] The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "SQL Server returned an incomplete response. The connection has been closed.".

    [2015-11-10 16:41:45.08] ERRORDTL [1447191705080]com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "SQL Server returned an incomplete response. The connection has been closed.".

  85. Ninad Gaonkar says:

    If you encounter connection issues from your Java application and SQL Server that are related to SSL, first check the Windows Server system event log if it contains SCHANNEL errors or warnings. If you see such entries you can test if SCHANNEL is misconfigured by first exporting the current registry key and then delete the complete

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL]

    key. Restart the computer and check if the JDBC connection works. If the connection works, ask your IT department, if they set these keys via group policy or if they use tools that configure SCHANNEL.

  86. Snehal says:

    I am accessing sql server using sql jdbc 4.0 jar. Its working fine for 95 times out of 100. But for remaining 5 times I am getting error as:
    The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: “SQL Server returned an incomplete response. The connection has been closed.”.

    This is not frequent error. we are using java 1.6_22.

    Can you please help me in resolving this issue?

    Thanks

  87. dgm116 says:

    Hi to everybody

    someone can help me?

    I have a problem with my java process, i just have to install the next patchs in a windows server 2008 R2:
    KB3179573
    KB3164033
    KB3161958
    KB2687499
    KB3177725
    KB3178034
    KB3168965
    KB3172605
    KB3161949
    KB3161561
    KB3170455
    KB3159398
    KB2596615
    Before the installtion the java process was executed without any problem but now i have the next exception:
    Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: “SQL Server returned an incomplete response. The connection has been closed.”.
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1368)
    at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1412)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1058)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:833)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:716)
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841)
    at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
    at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
    at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1158)
    at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)
    at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
    at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)

    Sometimes the process are executed without errors.
    JDK 6 u45 was grow up to JDK 7 u51 and the problem persist.

    SQL server 2008 R2 SP3

    I hope you can help me.

    Best regards.