Debugging SQL Server JDBC Driver

September 16, 2009 – 7:33 am

SQL Server JDBC Driver provides misleading error messages and sometimes even locks down processing SQL Query request.

In one of my application tests that used Hibernate  framework to abstract  database access, SQL Server JDBC Driver went into infinite loop trying to process a simple query on a view such as :

SELECT * FROM PARTITION_TABLE

It filled in seconds my 999999 Eclipse console buffer with junk messages such as:

Sep 15, 2009 5:20:45 PM com.microsoft.sqlserver.jdbc.TDSParser throwUnexpectedTokenException
SEVERE: ConnectionID:3: batch completion: Encountered unexpected unknown token (0x49)
Sep 15, 2009 5:20:45 PM com.microsoft.sqlserver.jdbc.TDSReader throwInvalidTDS
SEVERE: ConnectionID:3 got unexpected value in TDS response at offset:112

It was difficult to debug it. There was not much on the web on. I tried to switch drivers 2.0 to 1.2 different types and still got the same result. I also noticed that people were switching to an open source SQL Server JDBC Driver called – jTDS. The driver supports all SQL Server versions as well as XA or distributed transactions.

I also tried to simplify the query and the way I accessed the query via Hibernate. At the end I decided to try a simple JDBC access that gave me a meaningful error: “VARIANT is NOT SUPPORTED”. I updated my view to cast the problematic column into a NUMERIC and the problem was resolved.

Lesson: frameworks can be helpful and misleading. They filter information and might hide needed information. At the same time SQL Server error message can be interpreted as unexpected response but also as a sign that it was used incorrectly. Putting Hibernate out of the picture helped to identify the issue.

Sep 15, 2009 5:20:45 PM com.microsoft.sqlserver.jdbc.TDSParser throwUnexpectedTokenException

SEVERE: ConnectionID:3: batch completion: Encountered unexpected unknown token (0×49)

Sep 15, 2009 5:20:45 PM com.microsoft.sqlserver.jdbc.TDSReader throwInvalidTDS

SEVERE: ConnectionID:3 got unexpected value in TDS response at offset:112

No TweetBacks yet. (Be the first to Tweet this post)
Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • TwitThis

Post a Comment