duduamar
duduamar

Reputation: 3924

JDBC setQueryTimeout not working?

I'm querying MSSQL 2008 server thourgh JAVA, using the JDBC driver. I do something like this:

PreparedStatement stmt = ...;
...
stmt.setQueryTimeout(60);
stmt.executeQuery();

I see that when there's a load on the SQL server, the statement doesn't get cancelled even though the timeout has passed.

Does anyone have a clue about this?

Thanks.

Upvotes: 1

Views: 5732

Answers (1)

gbn
gbn

Reputation: 432260

  • The timing for setQueryTimeout is not precise at all
  • The exception relies on the server acknowledging the cancel command

So, YMMV unfortunately...

References: (can't find anything better, sorry)

Upvotes: 2

Related Questions