From f8029d145e6f4af1a311430a87b9c9d38d12da64 Mon Sep 17 00:00:00 2001
From: brinn <brinn>
Date: Tue, 13 Nov 2012 18:49:21 +0000
Subject: [PATCH] Remove a workaround for setting a query timeout that was
 PostgreSQL specific (i.e. broke functionality with Oracle) and that is now no
 longer needed as the current PostgreSQL JDBC driver works fine with
 Statement.setQueryTimeout().

SVN: 27599
---
 .../systemsx/cisd/openbis/plugin/query/server/DAO.java   | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/DAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/DAO.java
index 62a9da0fcc0..7dd423f2824 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/DAO.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/DAO.java
@@ -60,9 +60,7 @@ class DAO extends SimpleJdbcDaoSupport implements IDAO
 
     private static final int MAX_ROWS = 100 * FETCH_SIZE; // 100.000
 
-    private static final long MINUTE_MILIS = 60 * 1000;
-
-    private static final long QUERY_TIMEOUT_MILIS = 10 * MINUTE_MILIS;
+    private static final int QUERY_TIMEOUT_SECS = 5 * 60; // 5 minutes
 
     private static final String ENTITY_COLUMN_NAME_SUFFIX = "_KEY";
 
@@ -194,10 +192,7 @@ class DAO extends SimpleJdbcDaoSupport implements IDAO
         final JdbcTemplate template = getJdbcTemplate();
         template.setFetchSize(FETCH_SIZE);
         template.setMaxRows(MAX_ROWS + 1); // fetch one more row than allowed to detect excess
-        // WORKAROUND setQueryTimeout(int) is not implemented in the JDBC driver for PostgreSQL
-        // NOTE: This fallback solution is PostgreSQL specific!
-        // Setting timeout only once to all statements executed by this DAO doesn't seem to work.
-        template.execute("SET statement_timeout TO " + QUERY_TIMEOUT_MILIS);
+        template.setQueryTimeout(QUERY_TIMEOUT_SECS);
         final String resolvedQuery = createSQLQueryWithBindingsResolved(sqlQuery, bindingsOrNull);
         return (TableModel) template.execute(resolvedQuery, callback);
     }
-- 
GitLab