SQL Server Type 4 Drivers: jTDS
A couple months ago I wrote about problems I was having with Tomcat and SQL Server where I would get Connection reset by peer errors if the SQL Server was restarted. A couple people commented that instead of using the Microsoft provided JDBC SQL Server drivers, they had switched the open source jTDS driver available on sourceforge. I ignored them and went on my merry way, until yesterday when I ran into this really strange problem. I had a query written using Hibernate/HQL that would take approximately 10 seconds to run but the same query run in Query Analyzer would take less than 1 second. My code looked like this:
Query q = null;
Session session = HibernateFactory.currentSession();
String query = "select this and that from sometable";
q = session.createQuery(query);
List list = q.list();
for (int i = 0; i
Pretty simple, nothing out of the ordinary, it just took 10 seconds to go from the q.list() to the for {} block. I tried a bunch of different things: I modified the query, I tried using an Iterator rather than a List, I added named binding to the query. Nothing worked. Today I switched to the jTDS driver. Problem solved. I’ll never use the Microsoft JDBC drivers again.
6 Comments