https://issues.apache.org/jira/browse/AMQ-3681 - make use of java.sql.Statement#setQueryTimeout conditional on queryTimeout attribute > 0 so it can be disabled as it does not have universal support, default value 10 seconds

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1326610 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2012-04-16 13:28:52 +00:00
parent da7add92fe
commit 04aa9c5161
1 changed files with 11 additions and 1 deletions

View File

@ -47,6 +47,7 @@ public class DefaultDatabaseLocker implements DatabaseLocker {
protected Connection connection;
protected boolean stopping;
protected Handler<Exception> exceptionHandler;
protected int queryTimeout = 10;
public DefaultDatabaseLocker() {
}
@ -174,7 +175,9 @@ public class DefaultDatabaseLocker implements DatabaseLocker {
try {
lockUpdateStatement = connection.prepareStatement(statements.getLockUpdateStatement());
lockUpdateStatement.setLong(1, System.currentTimeMillis());
lockUpdateStatement.setQueryTimeout(10);
if (queryTimeout > 0) {
lockUpdateStatement.setQueryTimeout(queryTimeout);
}
int rows = lockUpdateStatement.executeUpdate();
if (rows == 1) {
result=true;
@ -210,4 +213,11 @@ public class DefaultDatabaseLocker implements DatabaseLocker {
this.exceptionHandler = exceptionHandler;
}
public int getQueryTimeout() {
return queryTimeout;
}
public void setQueryTimeout(int queryTimeout) {
this.queryTimeout = queryTimeout;
}
}