Select statement blocking when run through JDBC/jTDS
843859Feb 15 2008 — edited Nov 20 2014Hi,
I have a very simple statement that runs on a very large but indexed table on SQL Server 2000. If I simply run:
SELECT * FROM t1 WHERE x = 'y' and a = 'b'
... directly on the SQL Server Query analyser, or through various other API's (Coldfusion in this case) the results are returned in less than a second. However, when I implement the excact same query in JTDS as:
-----
String sql = "SELECT * FROM t1 WHERE x = ? and a = ?";
PreaparedStatement pstmt = con.prepareStatement(SQL);
pstmt.setString(1,"y");
pstmt.setString(2,"b");
ResultSet rs = pstmt.executeQuery();
-----
... this causes the query to block for a huge amount of time and make the database unusable until the process is killed.
Does anyone know what I'm missing here - from what I can see it's the same query so I dont understand why it only causes blocking when run through jTDS / JDBC
TIA
Craig