Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java	(revision 928618)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java	(working copy)
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.core.fs.db;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.core.StatementCache;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemPathUtil;
@@ -1089,6 +1090,12 @@
         int trials = 2;
         while (true) {
             PreparedStatement stmt = (PreparedStatement) preparedStatements.get(sql);
+            if (!StatementCache.isActive()) {
+                closeStatement(stmt);
+                stmt = con.prepareStatement(sql);
+                preparedStatements.put(sql, stmt);
+            }
+                        
             try {
                 for (int i = 0; i < params.length; i++) {
                     if (params[i] instanceof SizedInputStream) {
@@ -1322,43 +1329,27 @@
      * @throws SQLException if an error occurs
      */
     protected void initPreparedStatements() throws SQLException {
-        preparedStatements.put(
-                selectExistSQL, con.prepareStatement(selectExistSQL));
-        preparedStatements.put(
-                selectFileExistSQL, con.prepareStatement(selectFileExistSQL));
-        preparedStatements.put(
-                selectFolderExistSQL, con.prepareStatement(selectFolderExistSQL));
-        preparedStatements.put(
-                selectChildCountSQL, con.prepareStatement(selectChildCountSQL));
-        preparedStatements.put(
-                selectDataSQL, con.prepareStatement(selectDataSQL));
-        preparedStatements.put(
-                selectLastModifiedSQL, con.prepareStatement(selectLastModifiedSQL));
-        preparedStatements.put(
-                selectLengthSQL, con.prepareStatement(selectLengthSQL));
-        preparedStatements.put(
-                selectFileNamesSQL, con.prepareStatement(selectFileNamesSQL));
-        preparedStatements.put(
-                selectFolderNamesSQL, con.prepareStatement(selectFolderNamesSQL));
-        preparedStatements.put(
-                selectFileAndFolderNamesSQL, con.prepareStatement(selectFileAndFolderNamesSQL));
-        preparedStatements.put(
-                deleteFileSQL, con.prepareStatement(deleteFileSQL));
-        preparedStatements.put(
-                deleteFolderSQL, con.prepareStatement(deleteFolderSQL));
-        preparedStatements.put(
-                insertFileSQL, con.prepareStatement(insertFileSQL));
-        preparedStatements.put(
-                insertFolderSQL, con.prepareStatement(insertFolderSQL));
-        preparedStatements.put(
-                updateDataSQL, con.prepareStatement(updateDataSQL));
-        preparedStatements.put(
-                updateLastModifiedSQL, con.prepareStatement(updateLastModifiedSQL));
-        preparedStatements.put(
-                copyFileSQL, con.prepareStatement(copyFileSQL));
-        preparedStatements.put(
-                copyFilesSQL, con.prepareStatement(copyFilesSQL));
-
+        if (StatementCache.isActive()) {
+            preparedStatements.put(selectExistSQL, con.prepareStatement(selectExistSQL));
+            preparedStatements.put(selectFileExistSQL, con.prepareStatement(selectFileExistSQL));
+            preparedStatements.put(selectFolderExistSQL, con.prepareStatement(selectFolderExistSQL));
+            preparedStatements.put(selectChildCountSQL, con.prepareStatement(selectChildCountSQL));
+            preparedStatements.put(selectDataSQL, con.prepareStatement(selectDataSQL));
+            preparedStatements.put(selectLastModifiedSQL, con.prepareStatement(selectLastModifiedSQL));
+            preparedStatements.put(selectLengthSQL, con.prepareStatement(selectLengthSQL));
+            preparedStatements.put(selectFileNamesSQL, con.prepareStatement(selectFileNamesSQL));
+            preparedStatements.put(selectFolderNamesSQL, con.prepareStatement(selectFolderNamesSQL));
+            preparedStatements.put(selectFileAndFolderNamesSQL, con
+                .prepareStatement(selectFileAndFolderNamesSQL));
+            preparedStatements.put(deleteFileSQL, con.prepareStatement(deleteFileSQL));
+            preparedStatements.put(deleteFolderSQL, con.prepareStatement(deleteFolderSQL));
+            preparedStatements.put(insertFileSQL, con.prepareStatement(insertFileSQL));
+            preparedStatements.put(insertFolderSQL, con.prepareStatement(insertFolderSQL));
+            preparedStatements.put(updateDataSQL, con.prepareStatement(updateDataSQL));
+            preparedStatements.put(updateLastModifiedSQL, con.prepareStatement(updateLastModifiedSQL));
+            preparedStatements.put(copyFileSQL, con.prepareStatement(copyFileSQL));
+            preparedStatements.put(copyFilesSQL, con.prepareStatement(copyFilesSQL));
+        }
     }
 
     /**
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java	(revision 928618)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java	(working copy)
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.journal;
 
+import org.apache.jackrabbit.core.StatementCache;
 import org.apache.jackrabbit.core.persistence.bundle.util.ConnectionFactory;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.util.Text;
@@ -34,6 +35,8 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Iterator;
 
 import javax.jcr.RepositoryException;
 
@@ -145,51 +148,11 @@
     private Connection connection;
 
     /**
-     * Statement returning all revisions within a range.
+     * The map of prepared statements (key: SQL stmt, value: prepared stmt).
      */
-    private PreparedStatement selectRevisionsStmt;
-
-    /**
-     * Statement updating the global revision.
-     */
-    private PreparedStatement updateGlobalStmt;
-
-    /**
-     * Statement returning the global revision.
-     */
-    private PreparedStatement selectGlobalStmt;
-
-    /**
-     * Statement appending a new record.
-     */
-    private PreparedStatement insertRevisionStmt;
-
-    /**
-     * Statement returning the minimum of the local revisions.
-     */
-    private PreparedStatement selectMinLocalRevisionStmt;
-
-    /**
-     * Statement removing a set of revisions with from the journal table.
-     */
-    private PreparedStatement cleanRevisionStmt;
-
-    /**
-     * Statement returning the local revision of this cluster node.
-     */
-    private PreparedStatement getLocalRevisionStmt;
+    private HashMap preparedStatements = new HashMap();
     
     /**
-     * Statement for inserting the local revision of this cluster node. 
-     */
-    private PreparedStatement insertLocalRevisionStmt;
-    
-    /**
-     * Statement for updating the local revision of this cluster node. 
-     */
-    private PreparedStatement updateLocalRevisionStmt;
-
-    /**
      * Auto commit level.
      */
     private int lockLevel;
@@ -454,8 +417,7 @@
         try {
             checkConnection();
 
-            selectRevisionsStmt.clearParameters();
-            selectRevisionsStmt.clearWarnings();
+            PreparedStatement selectRevisionsStmt = getPreparedStatement(selectRevisionsStmtSQL);
             selectRevisionsStmt.setLong(1, startRevision);
             selectRevisionsStmt.execute();
 
@@ -468,16 +430,15 @@
             throw new JournalException(msg, e);
         }
     }
-
+    
     /**
      * {@inheritDoc}
      */
     public RecordIterator getRecords() throws JournalException {
         try {
             checkConnection();
-
-            selectRevisionsStmt.clearParameters();
-            selectRevisionsStmt.clearWarnings();
+            
+            PreparedStatement selectRevisionsStmt = getPreparedStatement(selectRevisionsStmtSQL);
             selectRevisionsStmt.setLong(1, Long.MIN_VALUE);
             selectRevisionsStmt.execute();
 
@@ -516,12 +477,10 @@
         }
 
         try {
-            updateGlobalStmt.clearParameters();
-            updateGlobalStmt.clearWarnings();
+            PreparedStatement updateGlobalStmt = getPreparedStatement(updateGlobalStmtSQL);
             updateGlobalStmt.execute();
 
-            selectGlobalStmt.clearParameters();
-            selectGlobalStmt.clearWarnings();
+            PreparedStatement selectGlobalStmt = getPreparedStatement(selectGlobalStmtSQL);
             selectGlobalStmt.execute();
 
             rs = selectGlobalStmt.getResultSet();
@@ -578,8 +537,7 @@
         try {
             checkConnection();
 
-            insertRevisionStmt.clearParameters();
-            insertRevisionStmt.clearWarnings();
+            PreparedStatement insertRevisionStmt = getPreparedStatement(insertRevisionStmtSQL);
             insertRevisionStmt.setLong(1, record.getRevision());
             insertRevisionStmt.setString(2, getId());
             insertRevisionStmt.setString(3, record.getProducerId());
@@ -616,24 +574,12 @@
             reconnectTimeMs = System.currentTimeMillis() + reconnectDelayMs;
         }
 
-        close(selectRevisionsStmt);
-        selectRevisionsStmt = null;
-        close(updateGlobalStmt);
-        updateGlobalStmt = null;
-        close(selectGlobalStmt);
-        selectGlobalStmt = null;
-        close(insertRevisionStmt);
-        insertRevisionStmt = null;
-        close(selectMinLocalRevisionStmt);
-        selectMinLocalRevisionStmt = null;
-        close(cleanRevisionStmt);
-        cleanRevisionStmt = null;
-        close(getLocalRevisionStmt);
-        getLocalRevisionStmt = null;
-        close(insertLocalRevisionStmt);
-        insertLocalRevisionStmt = null;
-        close(updateLocalRevisionStmt);
-        updateLocalRevisionStmt = null;
+        // close shared prepared statements
+        Iterator it = preparedStatements.values().iterator();
+        while (it.hasNext()) {
+            close((PreparedStatement) it.next());
+        }
+        preparedStatements.clear();
         
         close(connection);
         connection = null;
@@ -943,15 +889,22 @@
      * @throws SQLException if an error occurs
      */
     private void prepareStatements() throws SQLException {
-        selectRevisionsStmt = connection.prepareStatement(selectRevisionsStmtSQL);
-        updateGlobalStmt = connection.prepareStatement(updateGlobalStmtSQL);
-        selectGlobalStmt = connection.prepareStatement(selectGlobalStmtSQL);
-        insertRevisionStmt = connection.prepareStatement(insertRevisionStmtSQL);
-        selectMinLocalRevisionStmt = connection.prepareStatement(selectMinLocalRevisionStmtSQL);
-        cleanRevisionStmt = connection.prepareStatement(cleanRevisionStmtSQL);
-        getLocalRevisionStmt = connection.prepareStatement(getLocalRevisionStmtSQL);
-        insertLocalRevisionStmt = connection.prepareStatement(insertLocalRevisionStmtSQL);
-        updateLocalRevisionStmt = connection.prepareStatement(updateLocalRevisionStmtSQL);
+    	if (StatementCache.isActive()) {
+            preparedStatements.put(selectRevisionsStmtSQL, connection
+                .prepareStatement(selectRevisionsStmtSQL));
+            preparedStatements.put(updateGlobalStmtSQL, connection.prepareStatement(updateGlobalStmtSQL));
+            preparedStatements.put(selectGlobalStmtSQL, connection.prepareStatement(selectGlobalStmtSQL));
+            preparedStatements.put(insertRevisionStmtSQL, connection.prepareStatement(insertRevisionStmtSQL));
+            preparedStatements.put(selectMinLocalRevisionStmtSQL, connection
+                .prepareStatement(selectMinLocalRevisionStmtSQL));
+            preparedStatements.put(cleanRevisionStmtSQL, connection.prepareStatement(cleanRevisionStmtSQL));
+            preparedStatements.put(getLocalRevisionStmtSQL, connection
+                .prepareStatement(getLocalRevisionStmtSQL));
+            preparedStatements.put(insertLocalRevisionStmtSQL, connection
+                .prepareStatement(insertLocalRevisionStmtSQL));
+            preparedStatements.put(updateLocalRevisionStmtSQL, connection
+                .prepareStatement(updateLocalRevisionStmtSQL));
+        }
     }
 
     /**
@@ -1092,6 +1045,27 @@
     public final void setSchemaCheckEnabled(boolean enabled) {
         schemaCheckEnabled = enabled;
     }
+    
+    /**
+     * Returns a PreparedStatement based on its SQL. If statement cache is enable the cached statement is
+     * returned, otherwise a new statement is created.
+     * 
+     * @param statementSQL SQL of the statement
+     * @return the prepared statement
+     * @throws SQLException thrown is creation of PreparedStatement failed
+     */    
+    private PreparedStatement getPreparedStatement(String statementSQL) throws SQLException {
+        PreparedStatement preparedStatement = (PreparedStatement) preparedStatements.get(statementSQL);
+        if (StatementCache.isActive()) {
+            preparedStatement.clearParameters();
+            preparedStatement.clearWarnings();
+        } else {
+            close(preparedStatement);
+            preparedStatement = connection.prepareStatement(statementSQL);
+            preparedStatements.put(statementSQL, preparedStatement);
+        }
+        return preparedStatement;
+    }    
 
     /**
      * This class manages the local revision of the cluster node. It
@@ -1124,8 +1098,7 @@
                 checkConnection();
 
                 // Check whether there is an entry in the database.
-                getLocalRevisionStmt.clearParameters();
-                getLocalRevisionStmt.clearWarnings();
+                PreparedStatement getLocalRevisionStmt = getPreparedStatement(getLocalRevisionStmtSQL);
                 getLocalRevisionStmt.setString(1, getId());
                 getLocalRevisionStmt.execute();
                 ResultSet rs = getLocalRevisionStmt.getResultSet();
@@ -1137,8 +1110,7 @@
 
                 // Insert the given revision in the database
                 if (!exists) {
-                    insertLocalRevisionStmt.clearParameters();
-                    insertLocalRevisionStmt.clearWarnings();
+                    PreparedStatement insertLocalRevisionStmt = getPreparedStatement(insertLocalRevisionStmtSQL);
                     insertLocalRevisionStmt.setLong(1, revision);
                     insertLocalRevisionStmt.setString(2, getId());
                     insertLocalRevisionStmt.execute();
@@ -1155,8 +1127,25 @@
                 throw new JournalException("Failed to initialize local revision", e);
             }
         }
-
+        
         /**
+         * Close some statement.  Does nothing if the statement
+         * passed is <code>null</code> and logs any exception as warning.
+         *
+         * @param stmt statement, may be <code>null</code>.
+         */
+        private void close(Statement stmt) {
+            if (stmt != null) {
+                try {
+                    stmt.close();
+                } catch (SQLException e) {
+                    String msg = "Error while closing statement: " + e.getMessage();
+                    log.warn(msg);
+                }
+            }
+        }  
+        
+        /**
          * {@inheritDoc}
          */
         public synchronized long get() {
@@ -1179,8 +1168,7 @@
             try {
                 // Check whether the connection is available
                 checkConnection();
-                updateLocalRevisionStmt.clearParameters();
-                updateLocalRevisionStmt.clearWarnings();
+                PreparedStatement updateLocalRevisionStmt = getPreparedStatement(updateLocalRevisionStmtSQL);
                 updateLocalRevisionStmt.setLong(1, localRevision);
                 updateLocalRevisionStmt.setString(2, getId());
                 updateLocalRevisionStmt.execute();
@@ -1237,8 +1225,8 @@
                 checkConnection();
 
                 // Find the minimal local revision
-                selectMinLocalRevisionStmt.clearParameters();
-                selectMinLocalRevisionStmt.clearWarnings();
+                
+                PreparedStatement selectMinLocalRevisionStmt = getPreparedStatement(selectMinLocalRevisionStmtSQL);
                 selectMinLocalRevisionStmt.execute();
                 ResultSet rs = selectMinLocalRevisionStmt.getResultSet();
                 boolean cleanUp = rs.next();
@@ -1249,8 +1237,7 @@
 
                 // Clean up if necessary:
                 if (cleanUp) {
-                    cleanRevisionStmt.clearParameters();
-                    cleanRevisionStmt.clearWarnings();
+                    PreparedStatement cleanRevisionStmt = getPreparedStatement(cleanRevisionStmtSQL);
                     cleanRevisionStmt.setLong(1, minRevision);
                     cleanRevisionStmt.execute();
                     log.info("Cleaned old revisions up to revision " + minRevision + ".");
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionRecoveryManager.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionRecoveryManager.java	(revision 928618)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionRecoveryManager.java	(working copy)
@@ -27,6 +27,7 @@
 
 import javax.jcr.RepositoryException;
 
+import org.apache.jackrabbit.core.StatementCache;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -212,6 +213,10 @@
         PreparedStatement stmt = null;
         try {
             stmt = (PreparedStatement) preparedStatements.get(sql);
+        	if (!StatementCache.isActive()) {
+                close(stmt);
+                stmt = null;
+            }
             if (stmt == null) {
                 stmt = getConnection().prepareStatement(sql);
                 preparedStatements.put(sql, stmt);
@@ -222,7 +227,9 @@
             close();
             throw e;
         } finally {
-            resetStatement(stmt);
+            if (StatementCache.isActive()) {
+                resetStatement(stmt);
+            }   
         }
     }
 
@@ -286,6 +293,10 @@
                 key += " RETURN_GENERATED_KEYS";
             }
             PreparedStatement stmt = (PreparedStatement) preparedStatements.get(key);
+            if (!StatementCache.isActive()) {
+                close(stmt);
+                stmt = null;
+            }
             if (stmt == null) {
                 if (returnGeneratedKeys) {
                     stmt = getConnection().prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
@@ -322,6 +333,23 @@
         connection = null;
         isClosed = true;
     }
+    
+    /**
+     * Close some statement.  Does nothing if the statement
+     * passed is <code>null</code> and logs any exception as warning.
+     *
+     * @param stmt statement, may be <code>null</code>.
+     */
+    private static void close(Statement stmt) {
+        if (stmt != null) {
+            try {
+                stmt.close();
+            } catch (SQLException e) {
+                String msg = "Error while closing statement: " + e.getMessage();
+                log.warn(msg);
+            }
+        }
+    }    
 
     /**
      * Creates the database connection.
@@ -369,7 +397,9 @@
             }
         }
         stmt.execute();
-        resetStatement(stmt);
+        if (StatementCache.isActive()) {
+            resetStatement(stmt);
+        }
         return stmt;
     }
 
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java	(revision 928618)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java	(working copy)
@@ -19,6 +19,7 @@
 import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.StatementCache;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.local.LocalFileSystem;
 import org.apache.jackrabbit.core.persistence.AbstractPersistenceManager;
@@ -266,11 +267,11 @@
         }
 
         try {
-            // close shared prepared statements
-            for (Iterator it = preparedStatements.values().iterator(); it.hasNext();) {
-                closeStatement((PreparedStatement) it.next());
-            }
-            preparedStatements.clear();
+                // close shared prepared statements
+                for (Iterator it = preparedStatements.values().iterator(); it.hasNext();) {
+                    closeStatement((PreparedStatement) it.next());
+                }
+                preparedStatements.clear();
 
             if (externalBLOBs) {
                 // close BLOB file system
@@ -824,17 +825,17 @@
         // in any case try to shut down current connection
         // gracefully in order to avoid potential memory leaks
 
-        // close shared prepared statements
-        for (Iterator it = preparedStatements.values().iterator(); it.hasNext();) {
-            PreparedStatement stmt = ((PreparedStatement) it.next());
-            if (stmt != null) {
-                try {
-                    stmt.close();
-                } catch (SQLException se) {
-                    // ignored, see JCR-765
+            // close shared prepared statements
+            for (Iterator it = preparedStatements.values().iterator(); it.hasNext();) {
+                PreparedStatement stmt = ((PreparedStatement) it.next());
+                if (stmt != null) {
+                    try {
+                        stmt.close();
+                    } catch (SQLException se) {
+                        // ignored, see JCR-765
+                    }
                 }
             }
-        }
         try {
             closeConnection(con);
         } catch (Exception ignore) {
@@ -877,6 +878,11 @@
         int trials = autoReconnect ? 2 : 1;
         while (true) {
             PreparedStatement stmt = (PreparedStatement) preparedStatements.get(sql);
+            if (!StatementCache.isActive()) {
+                closeStatement(stmt);
+                stmt = con.prepareStatement(sql);
+                preparedStatements.put(sql, stmt);
+            }
             try {
                 for (int i = 0; i < params.length; i++) {
                     if (params[i] instanceof SizedInputStream) {
@@ -887,7 +893,9 @@
                     }
                 }
                 stmt.execute();
-                resetStatement(stmt);
+                if (StatementCache.isActive()) {
+                    resetStatement(stmt);
+                }
                 return stmt;
             } catch (SQLException se) {
                 if (--trials == 0) {
@@ -1139,45 +1147,34 @@
      * @throws SQLException if an error occurs
      */
     protected void initPreparedStatements() throws SQLException {
-        preparedStatements.put(
-                nodeStateInsertSQL, con.prepareStatement(nodeStateInsertSQL));
-        preparedStatements.put(
-                nodeStateUpdateSQL, con.prepareStatement(nodeStateUpdateSQL));
-        preparedStatements.put(
-                nodeStateSelectSQL, con.prepareStatement(nodeStateSelectSQL));
-        preparedStatements.put(
-                nodeStateSelectExistSQL, con.prepareStatement(nodeStateSelectExistSQL));
-        preparedStatements.put(
-                nodeStateDeleteSQL, con.prepareStatement(nodeStateDeleteSQL));
+    	if (StatementCache.isActive()) {
+            preparedStatements.put(nodeStateInsertSQL, con.prepareStatement(nodeStateInsertSQL));
+            preparedStatements.put(nodeStateUpdateSQL, con.prepareStatement(nodeStateUpdateSQL));
+            preparedStatements.put(nodeStateSelectSQL, con.prepareStatement(nodeStateSelectSQL));
+            preparedStatements.put(nodeStateSelectExistSQL, con.prepareStatement(nodeStateSelectExistSQL));
+            preparedStatements.put(nodeStateDeleteSQL, con.prepareStatement(nodeStateDeleteSQL));
 
-        preparedStatements.put(
-                propertyStateInsertSQL, con.prepareStatement(propertyStateInsertSQL));
-        preparedStatements.put(
-                propertyStateUpdateSQL, con.prepareStatement(propertyStateUpdateSQL));
-        preparedStatements.put(
-                propertyStateSelectSQL, con.prepareStatement(propertyStateSelectSQL));
-        preparedStatements.put(
-                propertyStateSelectExistSQL, con.prepareStatement(propertyStateSelectExistSQL));
-        preparedStatements.put(
-                propertyStateDeleteSQL, con.prepareStatement(propertyStateDeleteSQL));
+            preparedStatements.put(propertyStateInsertSQL, con.prepareStatement(propertyStateInsertSQL));
+            preparedStatements.put(propertyStateUpdateSQL, con.prepareStatement(propertyStateUpdateSQL));
+            preparedStatements.put(propertyStateSelectSQL, con.prepareStatement(propertyStateSelectSQL));
+            preparedStatements.put(propertyStateSelectExistSQL, con
+                .prepareStatement(propertyStateSelectExistSQL));
+            preparedStatements.put(propertyStateDeleteSQL, con.prepareStatement(propertyStateDeleteSQL));
 
-        preparedStatements.put(
-                nodeReferenceInsertSQL, con.prepareStatement(nodeReferenceInsertSQL));
-        preparedStatements.put(
-                nodeReferenceUpdateSQL, con.prepareStatement(nodeReferenceUpdateSQL));
-        preparedStatements.put(
-                nodeReferenceSelectSQL, con.prepareStatement(nodeReferenceSelectSQL));
-        preparedStatements.put(
-                nodeReferenceSelectExistSQL, con.prepareStatement(nodeReferenceSelectExistSQL));
-        preparedStatements.put(
-                nodeReferenceDeleteSQL, con.prepareStatement(nodeReferenceDeleteSQL));
+            preparedStatements.put(nodeReferenceInsertSQL, con.prepareStatement(nodeReferenceInsertSQL));
+            preparedStatements.put(nodeReferenceUpdateSQL, con.prepareStatement(nodeReferenceUpdateSQL));
+            preparedStatements.put(nodeReferenceSelectSQL, con.prepareStatement(nodeReferenceSelectSQL));
+            preparedStatements.put(nodeReferenceSelectExistSQL, con
+                .prepareStatement(nodeReferenceSelectExistSQL));
+            preparedStatements.put(nodeReferenceDeleteSQL, con.prepareStatement(nodeReferenceDeleteSQL));
 
-        if (!externalBLOBs) {
-            preparedStatements.put(blobInsertSQL, con.prepareStatement(blobInsertSQL));
-            preparedStatements.put(blobUpdateSQL, con.prepareStatement(blobUpdateSQL));
-            preparedStatements.put(blobSelectSQL, con.prepareStatement(blobSelectSQL));
-            preparedStatements.put(blobSelectExistSQL, con.prepareStatement(blobSelectExistSQL));
-            preparedStatements.put(blobDeleteSQL, con.prepareStatement(blobDeleteSQL));
+            if (!externalBLOBs) {
+                preparedStatements.put(blobInsertSQL, con.prepareStatement(blobInsertSQL));
+                preparedStatements.put(blobUpdateSQL, con.prepareStatement(blobUpdateSQL));
+                preparedStatements.put(blobSelectSQL, con.prepareStatement(blobSelectSQL));
+                preparedStatements.put(blobSelectExistSQL, con.prepareStatement(blobSelectExistSQL));
+                preparedStatements.put(blobDeleteSQL, con.prepareStatement(blobDeleteSQL));
+            }
         }
     }
 
Index: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/StatementCache.java
===================================================================
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/StatementCache.java	(revision 0)
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/StatementCache.java	(revision 0)
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Maintains whether statement cache is activated. The default is true, but this can be overridden by setting
+ * the org.apache.jackrabbit.core.statementcache property to false. If activated prepared statements will be
+ * be reused, otherwise a new prepared statements is created for each execution.
+ */
+public final class StatementCache {
+
+    /**
+     * Logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(StatementCache.class);
+
+    /**
+     * Name of the statement cache property.
+     */
+    private static final String STATEMENT_CACHE_PROPERTY = "org.apache.jackrabbit.core.statementcache";
+
+    /**
+     * Indicates whether statement cache is enabled and the default is true.
+     */
+    private static final boolean statementCacheActive = getStatementCacheProperty();
+
+    /**
+     * Returns the statement cache property.
+     * 
+     * @return the statement cache property
+     */
+    private static boolean getStatementCacheProperty() {
+        boolean statementCacheProperty = !"false".equalsIgnoreCase(System.getProperty(STATEMENT_CACHE_PROPERTY));
+        log.info("statementCache has been set to " + statementCacheProperty);
+        return statementCacheProperty;
+    }
+
+    /**
+     * Returns whether statement cache is active.
+     * 
+     * @return whether statement cache is active
+     */
+    public static boolean isActive() {
+        return statementCacheActive;
+    }
+
+}
