Index: src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java	(revision 577996)
+++ src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java	(working copy)
@@ -504,40 +504,36 @@
      * Basically wrapps a JDBC transaction around super.store().
      */
     public synchronized void store(ChangeLog changeLog) throws ItemStateException {
-        Connection con = null;
-        try {
-            boolean tryAgain = true;
-            do {
+        int trials = 2;
+        Throwable lastException  = null;
+        do {
+            trials--;
+            Connection con = null;
+            try {
+                con = connectionManager.getConnection();
+                connectionManager.setAutoReconnect(false);
+                con.setAutoCommit(false);
+                super.store(changeLog);
+                con.commit();
+                con.setAutoCommit(true);
+                return;
+            } catch (Throwable th) {
+                lastException = th;
                 try {
-                    con = connectionManager.getConnection();
-                    connectionManager.setAutoReconnect(false);
-                    con.setAutoCommit(false);
-                    super.store(changeLog);
-                    con.commit();
-                    con.setAutoCommit(true);
-                } catch (SQLException e) {
-                    if (tryAgain) {
-                        tryAgain = false;
-                        continue;
+                    if (con != null) {
+                        con.rollback();
                     }
-                    throw e;
+                } catch (SQLException e) {
+                    logException("rollback failed", e);
                 }
-            } while(false);
-        } catch (Throwable th) {
-            try {
-                if (con != null) {
-                    con.rollback();
+                if (th instanceof SQLException || th.getCause() instanceof SQLException) {
+                    connectionManager.close();
                 }
-            } catch (SQLException e) {
-                logException("rollback failed", e);
+            } finally {
+                connectionManager.setAutoReconnect(true);
             }
-            if (th instanceof SQLException || th.getCause() instanceof SQLException) {
-                connectionManager.close();
-            }
-            throw new ItemStateException(th.getMessage());
-        } finally {
-            connectionManager.setAutoReconnect(true);
-        }
+        } while(blockOnConnectionLoss || trials > 0);
+        throw new ItemStateException(lastException.getMessage());
     }
 
     /**
Index: src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionRecoveryManager.java
===================================================================
--- src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionRecoveryManager.java	(revision 577996)
+++ src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionRecoveryManager.java	(working copy)
@@ -172,13 +172,36 @@
     }
 
     /**
+     * Executes the given SQL query. Retries once or blocks (when the
+     * <code>block</code> parameter has been set to true on construction)
+     * if this fails and autoReconnect is enabled.
+     *
+     * @param sql the SQL query to execute
+     * @return the executed ResultSet
+     * @throws SQLException on error
+     */
+    public synchronized ResultSet executeQuery(String sql) throws SQLException {
+        int trials = 2;
+        SQLException lastException  = null;
+        do {
+            trials--;
+            try {
+                return executeQueryInternal(sql);
+            } catch (SQLException e) {
+                lastException = e;
+            }
+        } while(autoReconnect && (block || trials > 0));
+        throw lastException;
+    }
+
+    /**
      * Executes the given SQL query.
      *
      * @param sql query to execute
      * @return a <code>ResultSet</code> object
      * @throws SQLException if an error occurs
      */
-    public synchronized ResultSet executeQuery(String sql) throws SQLException {
+    private ResultSet executeQueryInternal(String sql) throws SQLException {
         PreparedStatement stmt = null;
         try {
             stmt = (PreparedStatement) preparedStatements.get(sql);
@@ -204,7 +227,7 @@
      * @return the <code>Statement</code> object that had been executed
      * @throws SQLException if an error occurs
      */
-    public synchronized Statement executeStmt(String sql, Object[] params) throws SQLException {
+    public Statement executeStmt(String sql, Object[] params) throws SQLException {
         return executeStmt(sql, params, false, 0);
     }    
 
@@ -219,6 +242,30 @@
      * @throws SQLException if an error occurs
      */
     public synchronized Statement executeStmt(String sql, Object[] params, boolean returnGeneratedKeys, int maxRows) throws SQLException {
+        int trials = 2;
+        SQLException lastException  = null;
+        do {
+            trials--;
+            try {
+                return executeStmtInternal(sql, params, returnGeneratedKeys, maxRows);
+            } catch (SQLException e) {
+                lastException = e;
+            }
+        } while(autoReconnect && (block || trials > 0));
+        throw lastException;
+    }
+
+    /**
+     * Executes the given SQL statement with the specified parameters.
+     *
+     * @param sql statement to execute
+     * @param params parameters to set
+     * @param returnGeneratedKeys if the statement should return auto generated keys
+     * @param maxRows the maximum number of rows to return (0 for all rows)
+     * @return the <code>Statement</code> object that had been executed
+     * @throws SQLException if an error occurs
+     */
+    private Statement executeStmtInternal(String sql, Object[] params, boolean returnGeneratedKeys, int maxRows) throws SQLException {
         try {
             String key = sql;
             if (returnGeneratedKeys) {
