Search code examples
javasql-serverjdbcspring-jdbc

SQL server connection issue using Spring


I found an issue connecting my web application using JDBC or Spring to a SQL Server database (not Express).

At some point of my code I call:

this.conn = DriverManager.getConnection(db_connect_string, db_userid, db_password);

and the application is running correctly but, it's waiting and doesn't proceed. The same happens with another web application with:

getJdbcTemplate().query(...)

If I take a look to the db using:

SELECT SPID, STATUS, PROGRAM_NAME, LOGINAME=RTRIM(LOGINAME), HOSTNAME, CMD
FROM MASTER.DBO.SYSPROCESSES
WHERE DB_NAME(DBID) = 'myDB' AND DBID != 0 

I can see there is a connection opened but "AWAITING COMMAND". No exception is handled, it's just waiting for something.

The SQL Server Profiler for that connection (Audit login) returns:

-- network protocol: TCP/IP
set quoted_identifier on
set arithabort off
set numeric_roundabort off
set ansi_warnings on
set ansi_padding on
set ansi_nulls on
set concat_null_yields_null on
set cursor_close_on_commit off
set implicit_transactions off
set language us_english
set dateformat mdy
set datefirst 7
set transaction isolation level read committed

It works until some weeks ago. I think it should be something related to SQLServer configuration, but I'm quite sure I didn't change anything. We can exclude a firewall issue because the connection is correctly created. Anyone could help me, please?


Solution

  • As suggested by Mark Rotteveel it's a Java 1.6.0_29 bug.