{"id":636,"date":"2004-10-15T07:16:59","date_gmt":"2004-10-15T11:16:59","guid":{"rendered":"http:\/\/wordpress.cephas.net\/?p=636"},"modified":"2004-10-15T07:16:59","modified_gmt":"2004-10-15T11:16:59","slug":"sql-server-type-4-drivers-jtds","status":"publish","type":"post","link":"https:\/\/cephas.net\/blog\/2004\/10\/15\/sql-server-type-4-drivers-jtds\/","title":{"rendered":"SQL Server Type 4 Drivers: jTDS"},"content":{"rendered":"<p>A couple months ago I <a href=\"http:\/\/cephas.net\/blog\/2004\/07\/14\/sql_server_2000_driver_for_jdbc_connection_reset_by_peer.html\">wrote about problems I was having with Tomcat and SQL Server<\/a> where I would get <code>Connection reset by peer<\/code> errors if the SQL Server was restarted.  A couple people commented that instead of using the <a href=\"http:\/\/www.microsoft.com\/downloads\/details.aspx?FamilyID=9f1874b6-f8e1-4bd6-947c-0fc5bf05bf71&amp;displaylang=en\">Microsoft provided JDBC SQL Server drivers<\/a>, they had switched the <a href=\"http:\/\/jtds.sourceforge.net\/\">open source jTDS driver<\/a> available on <a href=\"http:\/\/sourceforge.net\/\">sourceforge<\/a>.  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 <a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/qryanlzr\/qryanlzr_1zqq.asp\">Query Analyzer<\/a> would take less than 1 second. My code looked like this:<br \/>\n<code><br \/>\nQuery q = null;<br \/>\nSession session = HibernateFactory.currentSession();<br \/>\nString query = \"select this and that from sometable\";<br \/>\nq = session.createQuery(query);<br \/>\nList list = q.list();<br \/>\nfor (int i = 0; i<br \/>\nPretty simple, nothing out of the ordinary, it just took 10 seconds to go from the <code>q.list()<\/code> to the <code>for {}<\/code> block. I tried a bunch of different things: I modified the query, I tried using an <a href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/Iterator.html\">Iterator<\/a> rather than a <a href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/List.html\">List<\/a>, I added <a href=\"http:\/\/www.hibernate.org\/hib_docs\/reference\/en\/html\/manipulatingdata.html#manipulatingdata-queryinterface\">named binding<\/a> to the query.  Nothing worked.  Today I switched to the jTDS driver.  Problem solved. I'll never use the Microsoft JDBC drivers again.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/cephas.net\/blog\/2004\/10\/15\/sql-server-type-4-drivers-jtds\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">SQL Server Type 4 Drivers: jTDS<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/636"}],"collection":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/comments?post=636"}],"version-history":[{"count":0,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/636\/revisions"}],"wp:attachment":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/media?parent=636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/categories?post=636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/tags?post=636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}