jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1102269 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
Date Thu, 12 May 2011 12:44:44 GMT
Author: thomasm
Date: Thu May 12 12:44:43 2011
New Revision: 1102269

URL: http://svn.apache.org/viewvc?rev=1102269&view=rev
Log:
JCR-2026 DbDataStore: garbage collection deadlock (simplify using the ConnectionHelper)

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java?rev=1102269&r1=1102268&r2=1102269&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
Thu May 12 12:44:43 2011
@@ -280,8 +280,9 @@ public class ConnectionHelper {
                 stmt = con.createStatement();
                 stmt.execute(sql);
             } else {
-                stmt = con.prepareStatement(sql);
-                execute((PreparedStatement) stmt, params);
+                PreparedStatement p = con.prepareStatement(sql);
+                stmt = p;
+                execute(p, params);
             }
         } finally {
             closeResources(con, stmt, null);
@@ -296,7 +297,7 @@ public class ConnectionHelper {
      * @return the update count
      * @throws SQLException on error
      */
-    public final int update(final String sql, final Object[] params) throws SQLException
{
+    public final int update(final String sql, final Object... params) throws SQLException
{
         return new RetryManager<Integer>() {
 
             @Override
@@ -307,7 +308,7 @@ public class ConnectionHelper {
         }.doTry();
     }
 
-    int reallyUpdate(String sql, Object[] params) throws SQLException {
+    int reallyUpdate(String sql, Object... params) throws SQLException {
         Connection con = null;
         PreparedStatement stmt = null;
         try {
@@ -320,6 +321,19 @@ public class ConnectionHelper {
     }
 
     /**
+     * Executes a SQL query and returns the {@link ResultSet}. The
+     * returned {@link ResultSet} should be closed by clients.
+     *
+     * @param sql an SQL statement string
+     * @param params the parameters for the SQL statement
+     * @param returnGeneratedKeys whether generated keys should be returned
+     * @return a {@link ResultSet}
+     */
+    public final ResultSet query(String sql, Object... params) throws SQLException {
+        return exec(sql, params, false, 0);
+    }
+
+    /**
      * Executes a general SQL statement and returns the {@link ResultSet} of the executed
statement. The
      * returned {@link ResultSet} should be closed by clients.
      *



Mime
View raw message