MySQL Forums
Forum List  »  Connector/JDBC and Java

Controlling query timeout period for deadlocks and long running queries
Posted by: David Wynter
Date: June 03, 2005 11:09AM


Could not find a reference for how to do this. For lock timeouts in SQL Server I used to use this
timeoutStmt.executeUpdate("SET LOCK_TIMEOUT 20000");
This then works for just that connection. I catch the SQLException and test for
se.getErrorCode() == 1222
1222 being the native SQL server error code for a lock timeout.

How do I do the same in MySQL using JDBC? I was going to use
timeoutStmt.executeUpdate("SET @@session.wait_timeout = 20000");
until I realised wait_timeout is not related to the query but the connection.

Also of interest is when a query just takes too long, shouldn't happen, but I'd like to allow for it. Is there some way of setting a limit and a particular error code used when it is expired?



Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.