jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marti...@apache.org
Subject svn commit: r801659 [1/2] - in /jackrabbit/sandbox/JCR-1456/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/fs/db/ main/java/org/apache/jackrabbit/core/persistence/bundle/ main/java/org/apache/jackrabbit/core/persistence/bundle/util/ test/jav...
Date Thu, 06 Aug 2009 14:27:23 GMT
Author: martijnh
Date: Thu Aug  6 14:27:22 2009
New Revision: 801659

URL: http://svn.apache.org/viewvc?rev=801659&view=rev
Log:
JCR-1456 Database connection pooling

* Replaced the DataSource field with a ConnectionHelper field in BundleDbPersistenceManager
* removed the Context from the method signatures
* put the Context's state in the ConnectionHelper
* moved checkSchema and prepareSchemaObjectPrefix to the ConnectionHelper class

Added:
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DbUtility.java   (with props)
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DerbyConnectionHelper.java   (with props)
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ResultSetWrapper.java   (with props)
Modified:
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/MSSqlFileSystem.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/DerbyPersistenceManager.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/H2PersistenceManager.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/MSSqlPersistenceManager.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/OraclePersistenceManager.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/PostgreSQLPersistenceManager.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionHelper.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DbNameIndex.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NGKDbNameIndex.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/PostgreSQLNameIndex.java
    jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/db/DerbyFileSystemTest.java

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/MSSqlFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/MSSqlFileSystem.java?rev=801659&r1=801658&r2=801659&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/MSSqlFileSystem.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/MSSqlFileSystem.java Thu Aug  6 14:27:22 2009
@@ -85,9 +85,7 @@
         schema = "mssql";
         driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
         schemaObjectPrefix = "";
-        user = "";
-        password = "";
-        tableSpace = null;
+        tableSpace = "";
         initialized = false;
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java?rev=801659&r1=801658&r2=801659&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java Thu Aug  6 14:27:22 2009
@@ -18,7 +18,6 @@
 
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
 
 import javax.jcr.PropertyType;
@@ -47,14 +46,10 @@
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
 import org.apache.jackrabbit.core.state.PropertyState;
 import org.apache.jackrabbit.core.state.NodeState;
-import org.apache.jackrabbit.core.state.ChangeLog;
-import org.apache.jackrabbit.core.state.NodeReferences;
 import org.apache.jackrabbit.core.util.StringIndex;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * The <code>AbstractBundlePersistenceManager</code> acts as base for all
@@ -146,27 +141,6 @@
     public void setBundleCacheSize(String bundleCacheSize) {
         this.bundleCacheSize = Long.parseLong(bundleCacheSize) * 1024 * 1024;
     }
-
-    /**
-     * Holds "transactional" information for each call. This is used ensure that nested calls use
-     * same database connection as the caller methods. 
-     *
-     */
-    protected abstract class Context
-    {
-    	/**
-    	 * Method that creates context must call this to clean up.
-    	 */
-    	abstract void closeSilently();
-    };
-    
-    /**
-     * Creates new context object. Subclass can use this to propagate "transactional" information to
-     * nested methods.
-     * 
-     * @return new context instance
-     */
-    protected abstract Context createContext();
     
     /**
      * Creates the folder path for the given node id that is suitable for
@@ -354,7 +328,7 @@
      *         exist.
      * @throws ItemStateException if an error while loading occurs.
      */
-    protected abstract NodePropBundle loadBundle(NodeId id, Context context)
+    protected abstract NodePropBundle loadBundle(NodeId id)
             throws ItemStateException;
 
     /**
@@ -365,7 +339,7 @@
      *         <code>false</code> otherwise.
      * @throws ItemStateException if an error while checking occurs.
      */
-    protected abstract boolean existsBundle(NodeId id, Context context)
+    protected abstract boolean existsBundle(NodeId id)
             throws ItemStateException;
 
     /**
@@ -374,7 +348,7 @@
      * @param bundle the bundle to store
      * @throws ItemStateException if an error while storing occurs.
      */
-    protected abstract void storeBundle(NodePropBundle bundle, Context context)
+    protected abstract void storeBundle(NodePropBundle bundle)
             throws ItemStateException;
 
     /**
@@ -384,7 +358,7 @@
      *
      * @throws ItemStateException if an error while destroying occurs.
      */
-    protected abstract void destroyBundle(NodePropBundle bundle, Context context)
+    protected abstract void destroyBundle(NodePropBundle bundle)
             throws ItemStateException;
 
     /**
@@ -393,7 +367,7 @@
      * @param refs the node references to destroy.
      * @throws ItemStateException if an error while destroying occurs.
      */
-    protected abstract void destroy(NodeReferences refs, Context context)
+    protected abstract void destroy(NodeReferences refs)
             throws ItemStateException;
 
     /**
@@ -402,7 +376,7 @@
      * @param refs the node references to store.
      * @throws ItemStateException if an error while storing occurs.
      */
-    protected abstract void store(NodeReferences refs, Context context)
+    protected abstract void store(NodeReferences refs)
             throws ItemStateException;
 
     /**
@@ -453,18 +427,12 @@
      *
      * Loads the state via the appropriate NodePropBundle.
      */
-    public synchronized NodeState load(NodeId id)
-            throws NoSuchItemStateException, ItemStateException {
-    	Context context = createContext();
-    	try {
-    		NodePropBundle bundle = getBundle(id, context);
-    		if (bundle == null) {
-                throw new NoSuchItemStateException(id.toString());
-            }
-            return bundle.createNodeState(this);
-    	} finally {
-    		context.closeSilently();
-    	}        
+    public synchronized NodeState load(NodeId id) throws NoSuchItemStateException, ItemStateException {
+        NodePropBundle bundle = getBundle(id);
+        if (bundle == null) {
+            throw new NoSuchItemStateException(id.toString());
+        }
+        return bundle.createNodeState(this);
     }
 
     /**
@@ -472,45 +440,39 @@
      *
      * Loads the state via the appropriate NodePropBundle.
      */
-    public synchronized PropertyState load(PropertyId id)
-            throws NoSuchItemStateException, ItemStateException {
-    	Context context = createContext();
-    	try {
-            NodePropBundle bundle = getBundle(id.getParentId(), context);
-            if (bundle == null) {
+    public synchronized PropertyState load(PropertyId id) throws NoSuchItemStateException, ItemStateException {
+        NodePropBundle bundle = getBundle(id.getParentId());
+        if (bundle == null) {
+            throw new NoSuchItemStateException(id.toString());
+        }
+        PropertyState state = bundle.createPropertyState(this, id.getName());
+        if (state == null) {
+            // check if autocreated property state
+            if (id.getName().equals(NameConstants.JCR_UUID)) {
+                state = createNew(id);
+                state.setType(PropertyType.STRING);
+                state.setDefinitionId(idJcrUUID);
+                state.setMultiValued(false);
+                state.setValues(new InternalValue[]{InternalValue.create(id.getParentId().toString())});
+            } else if (id.getName().equals(NameConstants.JCR_PRIMARYTYPE)) {
+                state = createNew(id);
+                state.setType(PropertyType.NAME);
+                state.setDefinitionId(idJcrPrimaryType);
+                state.setMultiValued(false);
+                state.setValues(new InternalValue[]{InternalValue.create(bundle.getNodeTypeName())});
+            } else if (id.getName().equals(NameConstants.JCR_MIXINTYPES)) {
+                Set<Name> mixins = bundle.getMixinTypeNames();
+                state = createNew(id);
+                state.setType(PropertyType.NAME);
+                state.setDefinitionId(idJcrMixinTypes);
+                state.setMultiValued(true);
+                state.setValues(InternalValue.create((Name[]) mixins.toArray(new Name[mixins.size()])));
+            } else {
                 throw new NoSuchItemStateException(id.toString());
             }
-            PropertyState state = bundle.createPropertyState(this, id.getName());
-            if (state == null) {
-                // check if autocreated property state
-                if (id.getName().equals(NameConstants.JCR_UUID)) {
-                    state = createNew(id);
-                    state.setType(PropertyType.STRING);
-                    state.setDefinitionId(idJcrUUID);
-                    state.setMultiValued(false);
-                    state.setValues(new InternalValue[]{InternalValue.create(id.getParentId().toString())});
-                } else if (id.getName().equals(NameConstants.JCR_PRIMARYTYPE)) {
-                    state = createNew(id);
-                    state.setType(PropertyType.NAME);
-                    state.setDefinitionId(idJcrPrimaryType);
-                    state.setMultiValued(false);
-                    state.setValues(new InternalValue[]{InternalValue.create(bundle.getNodeTypeName())});
-                } else if (id.getName().equals(NameConstants.JCR_MIXINTYPES)) {
-                    Set<Name> mixins = bundle.getMixinTypeNames();
-                    state = createNew(id);
-                    state.setType(PropertyType.NAME);
-                    state.setDefinitionId(idJcrMixinTypes);
-                    state.setMultiValued(true);
-                    state.setValues(InternalValue.create((Name[]) mixins.toArray(new Name[mixins.size()])));
-                } else {
-                    throw new NoSuchItemStateException(id.toString());
-                }
-                bundle.addProperty(state);
-            }
-            return state;
-    	} finally {
-    	    context.closeSilently();
-    	}
+            bundle.addProperty(state);
+        }
+        return state;
     }
 
     /**
@@ -519,13 +481,8 @@
      * Loads the state via the appropriate NodePropBundle.
      */
     public synchronized boolean exists(PropertyId id) throws ItemStateException {
-    	Context context = createContext();
-    	try {
-    		NodePropBundle bundle = getBundle(id.getParentId(), context);
-    		return bundle != null && bundle.hasProperty(id.getName());
-    	} finally {
-    		context.closeSilently();
-    	}
+        NodePropBundle bundle = getBundle(id.getParentId());
+        return bundle != null && bundle.hasProperty(id.getName());
     }
 
     /**
@@ -534,13 +491,8 @@
      * Checks the existence via the appropriate NodePropBundle.
      */
     public synchronized boolean exists(NodeId id) throws ItemStateException {
-    	Context context = createContext();
-    	try {
         // anticipating a load followed by a exists
-    		return getBundle(id, context) != null;
-    	} finally {
-    		context.closeSilently();
-    	}
+        return getBundle(id) != null;
     }
 
     /**
@@ -566,11 +518,11 @@
      *
      * {@inheritDoc}
      */
-    public synchronized void store(ChangeLog changeLog, Context context)
+    public synchronized void store(ChangeLog changeLog)
             throws ItemStateException {
         boolean success = false;
         try {
-            storeInternal(changeLog, context);
+            storeInternal(changeLog);
             success = true;
         } finally {
             if (!success) {
@@ -579,20 +531,6 @@
             }
         }
     }
-    
-    /**
-     * {@inheritDoc}
-     */
-    public final synchronized void store(ChangeLog changeLog)
-    	throws ItemStateException
-    {
-    	Context context = createContext();
-    	try {
-    		store(changeLog, context);
-    	} finally {
-    		context.closeSilently();
-    	}
-    }
 
     /**
      * Stores the given changelog and updates the bundle cache.
@@ -600,17 +538,17 @@
      * @param changeLog the changelog to store
      * @throws ItemStateException on failure
      */
-    private void storeInternal(ChangeLog changeLog, Context context)
+    private void storeInternal(ChangeLog changeLog)
             throws ItemStateException {
         // delete bundles
         HashSet<ItemId> deleted = new HashSet<ItemId>();
         for (ItemState state : changeLog.deletedStates()) {
             if (state.isNode()) {
-                NodePropBundle bundle = getBundle((NodeId) state.getId(), context);
+                NodePropBundle bundle = getBundle((NodeId) state.getId());
                 if (bundle == null) {
                     throw new NoSuchItemStateException(state.getId().toString());
                 }
-                deleteBundle(bundle, context);
+                deleteBundle(bundle);
                 deleted.add(state.getId());
             }
         }
@@ -628,7 +566,7 @@
                 NodeId nodeId = (NodeId) state.getId();
                 NodePropBundle bundle = (NodePropBundle) modified.get(nodeId);
                 if (bundle == null) {
-                    bundle = getBundle(nodeId, context);
+                    bundle = getBundle(nodeId);
                     if (bundle == null) {
                         throw new NoSuchItemStateException(nodeId.toString());
                     }
@@ -646,7 +584,7 @@
                 NodeId nodeId = id.getParentId();
                 NodePropBundle bundle = (NodePropBundle) modified.get(nodeId);
                 if (bundle == null) {
-                    bundle = getBundle(nodeId, context);
+                    bundle = getBundle(nodeId);
                     if (bundle == null) {
                         throw new NoSuchItemStateException(nodeId.toString());
                     }
@@ -671,7 +609,7 @@
                     if (bundle == null) {
                         // should actually not happen
                         log.warn("deleted property state's parent not modified!");
-                        bundle = getBundle(nodeId, context);
+                        bundle = getBundle(nodeId);
                         if (bundle == null) {
                             throw new NoSuchItemStateException(nodeId.toString());
                         }
@@ -696,7 +634,7 @@
                 if (bundle == null) {
                     // should actually not happen
                     log.warn("added property state's parent not modified!");
-                    bundle = getBundle(nodeId, context);
+                    bundle = getBundle(nodeId);
                     if (bundle == null) {
                         throw new NoSuchItemStateException(nodeId.toString());
                     }
@@ -708,15 +646,15 @@
 
         // now store all modified bundles
         for (NodePropBundle bundle : modified.values()) {
-            putBundle(bundle, context);
+            putBundle(bundle);
         }
 
         // store the refs
         for (NodeReferences refs : changeLog.modifiedRefs()) {
             if (refs.hasReferences()) {
-                store(refs, context);
+                store(refs);
             } else {
-                destroy(refs, context);
+                destroy(refs);
             }
         }
     }
@@ -729,13 +667,13 @@
      *
      * @throws ItemStateException if an error occurs.
      */
-    private NodePropBundle getBundle(NodeId id, Context context) throws ItemStateException {
+    private NodePropBundle getBundle(NodeId id) throws ItemStateException {
         if (missing.contains(id)) {
             return null;
         }
         NodePropBundle bundle = bundles.get(id);
         if (bundle == null) {
-            bundle = loadBundle(id, context);
+            bundle = loadBundle(id);
             if (bundle != null) {
                 bundle.markOld();
                 bundles.put(bundle);
@@ -752,8 +690,8 @@
      * @param bundle the bundle to delete
      * @throws ItemStateException if an error occurs
      */
-    private void deleteBundle(NodePropBundle bundle, Context context) throws ItemStateException {
-        destroyBundle(bundle, context);
+    private void deleteBundle(NodePropBundle bundle) throws ItemStateException {
+        destroyBundle(bundle);
         bundle.removeAllProperties();
         bundles.remove(bundle.getId());
         missing.put(bundle.getId());
@@ -765,8 +703,8 @@
      * @param bundle the bundle to store
      * @throws ItemStateException if an error occurs
      */
-    private void putBundle(NodePropBundle bundle, Context context) throws ItemStateException {
-        storeBundle(bundle, context);
+    private void putBundle(NodePropBundle bundle) throws ItemStateException {
+        storeBundle(bundle);
         bundle.markOld();
         log.debug("stored bundle " + bundle.getId());
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java?rev=801659&r1=801658&r2=801659&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java Thu Aug  6 14:27:22 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.core.persistence.bundle;
 
-import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
@@ -25,14 +24,10 @@
 import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.sql.Blob;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -51,6 +46,7 @@
 import org.apache.jackrabbit.core.persistence.bundle.util.ConnectionFactory;
 import org.apache.jackrabbit.core.persistence.bundle.util.ConnectionHelper;
 import org.apache.jackrabbit.core.persistence.bundle.util.DbNameIndex;
+import org.apache.jackrabbit.core.persistence.bundle.util.DbUtility;
 import org.apache.jackrabbit.core.persistence.bundle.util.ErrorHandling;
 import org.apache.jackrabbit.core.persistence.bundle.util.NodePropBundle;
 import org.apache.jackrabbit.core.persistence.bundle.util.StreamWrapper;
@@ -120,7 +116,7 @@
     /** the database type */
     protected String databaseType;
     
-    protected DataSource dataSource;
+    protected ConnectionHelper conHelper;
 
     /** the prefix for the database objects */
     protected String schemaObjectPrefix;
@@ -181,54 +177,6 @@
      */
     private String name = super.toString();
 
-    protected class BundleDbContext extends Context
-    {
-    	/**
-         * The class that manages statement execution and recovery from connection loss.
-         */
-        
-        public BundleDbContext() {
-        
-		}
-        
-        private Connection connection;
-        
-        /**
-         * Lazily intiialize database connection
-         * @return
-         * @throws SQLException
-         * @throws RepositoryException
-         */
-        public Connection getConnection() throws SQLException, RepositoryException
-        {
-        	if (connection == null)
-        	{
-        		connection = dataSource.getConnection();
-        	}
-        	return connection;
-        }
-        
-        public ConnectionHelper getConnectionHelper() throws SQLException, RepositoryException
-        {
-        	return new ConnectionHelper(getConnection());
-        }
-        
-        public void closeSilently(Statement statement)
-        {
-        	ConnectionHelper.closeSilently(statement);
-        }
-        
-        public void closeSilently()
-        {
-        	ConnectionHelper.closeSilently(connection);
-        }
-    };
-    
-    @Override
-    protected BundleDbContext createContext() {
-    	return new BundleDbContext();
-    }
-
     /**
      * Returns the configured JDBC connection url.
      * @return the configured JDBC connection url.
@@ -476,100 +424,17 @@
     }
 
     /**
-     * Checks if the required schema objects exist and creates them if they
-     * don't exist yet.
-     *
-     * @throws SQLException if an SQL error occurs.
-     * @throws RepositoryException if an error occurs.
-     */
-    protected void checkSchema() throws SQLException, RepositoryException {
-        if (!checkTablesExist()) {
-            // read ddl from resources
-            InputStream in = BundleDbPersistenceManager.class.getResourceAsStream(databaseType + ".ddl");
-            if (in == null) {
-                String msg = "Configuration error: The resource '" + databaseType + ".ddl' could not be found";
-                log.debug(msg);
-                throw new RepositoryException(msg);
-            }
-            BufferedReader reader = new BufferedReader(new InputStreamReader(in));
-            BundleDbContext context = createContext();
-            
-            Statement stmt = null;
-            String sql = null;
-            try {
-            	stmt = context.getConnection().createStatement();
-                sql = reader.readLine();
-                while (sql != null) {
-                    if (!sql.startsWith("#") && sql.length() > 0
-                            && (sql.indexOf("BINVAL") < 0 || useDbBlobStore())) {
-                        // only create blob related tables of db blob store configured
-                        // execute sql stmt
-                        sql = createSchemaSQL(sql);
-                        stmt.executeUpdate(sql);
-                    }
-                    // read next sql stmt
-                    sql = reader.readLine();
-                }
-            } catch (IOException e) {
-                String msg = "Configuration error: unable to read the resource '" + databaseType + ".ddl': " + e;
-                log.debug(msg);
-                throw new RepositoryException(msg, e);
-            } catch (SQLException e) {
-                String msg = "Schema generation error: Issuing statement: " + sql;
-                SQLException se = new SQLException(msg);
-                se.initCause(e);
-                throw se;
-            } finally {
-                IOUtils.closeQuietly(in);
-                context.closeSilently(stmt);                
-                context.closeSilently();
-            }
-        }
-    }
-
-    /**
      * Creates an SQL statement for schema creation by variable substitution.
      *
      * @param sql a SQL string which may contain variables to substitute
      * @return a valid SQL string
      */
-    protected String createSchemaSQL(String sql) {
+    public String createSchemaSQL(String sql) {
         // replace prefix variable
         return Text.replace(sql, SCHEMA_OBJECT_PREFIX_VARIABLE, schemaObjectPrefix).trim();
     }
 
     /**
-     * Checks if the database table exist.
-     *
-     * @return <code>true</code> if the tables exist;
-     *         <code>false</code> otherwise.
-     *
-     * @throws SQLException if a database error occurs.
-     * @throws RepositoryException if a repository exception occurs.
-     */
-    protected boolean checkTablesExist() throws SQLException, RepositoryException {
-    	BundleDbContext context = createContext();
-    	try {
-	        DatabaseMetaData metaData = context.getConnection().getMetaData();
-	        String tableName = schemaObjectPrefix + "BUNDLE";
-	        if (metaData.storesLowerCaseIdentifiers()) {
-	            tableName = tableName.toLowerCase();
-	        } else if (metaData.storesUpperCaseIdentifiers()) {
-	            tableName = tableName.toUpperCase();
-	        }
-	        String userName = checkTablesWithUser() ? metaData.getUserName() : null;
-	        ResultSet rs = metaData.getTables(null, userName, tableName, null);
-	        try {
-	            return rs.next();
-	        } finally {
-	            rs.close();
-	        }
-    	} finally {
-    		context.closeSilently();
-    	}
-    }
-
-    /**
      * Indicates if the user name should be included when retrieving the tables
      * during {@link #checkTablesExist()}.
      * <p/>
@@ -578,7 +443,7 @@
      *
      * @return <code>false</code>
      */
-    protected boolean checkTablesWithUser() {
+    public boolean checkTablesWithUser() {
         return false;
     }
 
@@ -587,32 +452,26 @@
      *
      * Basically wraps a JDBC transaction around super.store().
      */
-    public synchronized void store(ChangeLog changeLog, Context context) throws ItemStateException {
-        int trials = 2;
-        Throwable lastException  = null;        
-        do {
-            trials--;
-            Connection con = null;
-            
+    public synchronized void store(ChangeLog changeLog) throws ItemStateException {
+        // FIXME: rethink blockOnConnectionLoss property
+        boolean transactionStarted = false;
+        boolean transactionEnded = false;
+        try {
+            conHelper.startBatch();
+            transactionStarted = true;
+            super.store(changeLog);
+            transactionEnded = true;
+            conHelper.endBatch(true);
+        } catch (Throwable th) {
             try {
-                con = ((BundleDbContext)context).getConnection();                
-                con.setAutoCommit(false);
-                super.store(changeLog, context);
-                con.commit();
-                con.setAutoCommit(true);
-                return;
-            } catch (Throwable th) {
-                lastException = th;
-                try {
-                    if (con != null) {
-                        con.rollback();
-                    }
-                } catch (SQLException e) {
-                    logException("rollback failed", e);
-                }                
-            } 
-        } while(blockOnConnectionLoss || trials > 0);
-        throw new ItemStateException(lastException.getMessage(), lastException);
+                if (transactionStarted && !transactionEnded) {
+                    conHelper.endBatch(false);
+                }
+            } catch (SQLException e) {
+                logException("rollback failed", e);
+            }
+            throw new ItemStateException(th.getMessage(), th);
+        }
     }
 
     /**
@@ -624,15 +483,17 @@
         }
         super.init(context);
 
-        dataSource = ConnectionFactory.getDataSource(getDriver(), getUrl(), getUser(), getPassword());
+        conHelper = createConnectionHelper(ConnectionFactory.getDataSource(getDriver(), getUrl(), getUser(),
+                getPassword()));
         
         this.name = context.getHomeDir().getName();        
 
         // make sure schemaObjectPrefix consists of legal name characters only
-        prepareSchemaObjectPrefix();
+        schemaObjectPrefix = conHelper.prepareDbIdentifier(schemaObjectPrefix);
 
         // check if schema objects exist and create them if necessary
-        checkSchema();
+        conHelper.checkSchema(BundleDbPersistenceManager.class.getResourceAsStream(databaseType + ".ddl"),
+            schemaObjectPrefix + "BUNDLE", this);
 
         // create correct blob store
         blobStore = createBlobStore();
@@ -653,6 +514,18 @@
     }
 
     /**
+     * This method is called from the {@link #init(PMContext)} method of this class and returns a
+     * {@link ConnectionHelper} instance. Subclasses may override it to return a specialized
+     * connection helper.
+     * 
+     * @param dataSrc the {@link DataSource} of this peristence manager
+     * @return a {@link ConnectionHelper}
+     */
+    protected ConnectionHelper createConnectionHelper(DataSource dataSrc) {
+        return new ConnectionHelper(dataSrc);
+    }
+
+    /**
      * {@inheritDoc}
      */
     protected BundleBinding getBinding() {
@@ -703,7 +576,7 @@
      * @throws SQLException if an SQL error occurs.
      */
     protected DbNameIndex createDbNameIndex() throws SQLException {
-        return new DbNameIndex(dataSource, schemaObjectPrefix);
+        return new DbNameIndex(conHelper, schemaObjectPrefix);
     }
 
     /**
@@ -759,8 +632,7 @@
      * {@linkplain NodePropBundle bundles} here
      */
     protected void checkBundleConsistency(NodeId id, NodePropBundle bundle,
-                                          boolean fix, Collection<NodePropBundle> modifications,
-                                          BundleDbContext context) {
+                                          boolean fix, Collection<NodePropBundle> modifications) {
         //log.info(name + ": checking bundle '" + id + "'");
 
         // skip all system nodes except root node
@@ -780,7 +652,7 @@
 
             try {
                 // analyze child node bundles
-                NodePropBundle child = loadBundle(entry.getId(), true, context);
+                NodePropBundle child = loadBundle(entry.getId(), true);
                 if (child == null) {
                     log.error(
                             "NodeState '" + id + "' references inexistent child"
@@ -812,7 +684,7 @@
         try {
             // skip root nodes (that point to itself)
             if (parentId != null && !id.toString().endsWith("babecafebabe")) {
-                if (!existsBundle(parentId, context)) {
+                if (!existsBundle(parentId)) {
                     log.error("NodeState '" + id + "' references inexistent parent uuid '" + parentId + "'");
                 }
             }
@@ -821,7 +693,7 @@
         }
     }
 
-    public void checkConsistency(String[] uuids, boolean recursive, boolean fix, BundleDbContext context) {
+    public void checkConsistency(String[] uuids, boolean recursive, boolean fix) {
         int count = 0;
         int total = 0;
         Collection<NodePropBundle> modifications = new ArrayList<NodePropBundle>();        
@@ -832,24 +704,22 @@
             ResultSet rs = null;
             try {            	
                 String sql = "select count(*) from " + schemaObjectPrefix + "BUNDLE";
-                Statement stmt = context.getConnectionHelper().executeStmt(sql, new Object[0]);
+                rs = conHelper.exec(sql, new Object[0], false, 0);
                 try {
-                    rs = stmt.getResultSet();
                     if (!rs.next()) {
                         log.error("Could not retrieve total number of bundles. empty result set.");
                         return;
                     }
                     total = rs.getInt(1);
                 } finally {
-                    closeResultSet(rs);
+                    DbUtility.close(rs);
                 }
                 if (getStorageModel() == SM_BINARY_KEYS) {
                     sql = "select NODE_ID from " + schemaObjectPrefix + "BUNDLE";
                 } else {
                     sql = "select NODE_ID_HI, NODE_ID_LO from " + schemaObjectPrefix + "BUNDLE";
                 }
-                stmt = context.getConnectionHelper().executeStmt(sql, new Object[0]);
-                rs = stmt.getResultSet();
+                rs = conHelper.exec(sql, new Object[0], false, 0);
 
                 // iterate over all node bundles in the db
                 while (rs.next()) {
@@ -864,15 +734,14 @@
                     ResultSet bRs = null;
                     byte[] data = null;
                     try {
-                        Statement bSmt = context.getConnectionHelper().executeStmt(bundleSelectSQL, getKey(id));
-                        bRs = bSmt.getResultSet();
+                        bRs = conHelper.exec(bundleSelectSQL, getKey(id), false, 0);
                         if (!bRs.next()) {
                             throw new SQLException("bundle cannot be retrieved?");
                         }
                         Blob blob = bRs.getBlob(1);
                         data = getBytes(blob);
                     } finally {
-                        closeResultSet(bRs);
+                        DbUtility.close(bRs);
                     }
 
 
@@ -884,7 +753,7 @@
                             // reset stream for readBundle()
                             din = new DataInputStream(new ByteArrayInputStream(data));
                             NodePropBundle bundle = binding.readBundle(din, id);
-                            checkBundleConsistency(id, bundle, fix, modifications, context);
+                            checkBundleConsistency(id, bundle, fix, modifications);
                         } else {
                             log.error("invalid bundle '" + id + "', see previous BundleBinding error log entry");
                         }
@@ -899,7 +768,7 @@
             } catch (Exception e) {
                 log.error("Error loading bundle", e);
             } finally {            	
-                closeResultSet(rs);
+                DbUtility.close(rs);
                 total = count;
             }
         } else {
@@ -926,14 +795,14 @@
                 NodeId id = idList.get(i);
                 try {
                     // load the node from the database
-                    NodePropBundle bundle = loadBundle(id, true, context);
+                    NodePropBundle bundle = loadBundle(id, true);
 
                     if (bundle == null) {
                         log.error("No bundle found for uuid '" + id + "'");
                         continue;
                     }
 
-                    checkBundleConsistency(id, bundle, fix, modifications, context);
+                    checkBundleConsistency(id, bundle, fix, modifications);
 
                     if (recursive) {
                         for (NodePropBundle.ChildNodeEntry entry : bundle.getChildNodeEntries()) {
@@ -960,7 +829,7 @@
                 try {
                     log.info(name + ": Fixing bundle '" + bundle.getId() + "'");
                     bundle.markOld(); // use UPDATE instead of INSERT
-                    storeBundle(bundle, context);
+                    storeBundle(bundle);
                     evictBundle(bundle.getId());
                 } catch (ItemStateException e) {
                     log.error(name + ": Error storing fixed bundle: " + e);
@@ -970,54 +839,6 @@
 
         log.info(name + ": checked " + count + "/" + total + " bundles.");
     }
-    
-    /**
-     * {@inheritDoc}
-     */
-    public void checkConsistency(String[] uuids, boolean recursive, boolean fix) {
-        log.info("{}: checking workspace consistency...", name);
-
-        BundleDbContext context = createContext();
-        try {
-        	checkConsistency(uuids, recursive, fix, context);
-        } finally {
-        	context.closeSilently();
-        }   
-    }
-
-    /**
-     * Makes sure that <code>schemaObjectPrefix</code> does only consist of
-     * characters that are allowed in names on the target database. Illegal
-     * characters will be escaped as necessary.
-     *
-     * @throws Exception if an error occurs
-     */
-    protected void prepareSchemaObjectPrefix() throws Exception {
-    	BundleDbContext context = createContext();
-    	try {    	
-	        DatabaseMetaData metaData = context.getConnection().getMetaData();
-	        String legalChars = metaData.getExtraNameCharacters();
-	        legalChars += "ABCDEFGHIJKLMNOPQRSTUVWXZY0123456789_";
-	
-	        String prefix = schemaObjectPrefix.toUpperCase();
-	        StringBuffer escaped = new StringBuffer();
-	        for (int i = 0; i < prefix.length(); i++) {
-	            char c = prefix.charAt(i);
-	            if (legalChars.indexOf(c) == -1) {
-	                escaped.append("_x");
-	                String hex = Integer.toHexString(c);
-	                escaped.append("0000".toCharArray(), 0, 4 - hex.length());
-	                escaped.append(hex);
-	                escaped.append("_");
-	            } else {
-	                escaped.append(c);
-	            }
-	        }
-	        schemaObjectPrefix = escaped.toString();
-    	} finally {
-    		context.closeSilently();
-    	}
-    }
 
     /**
      * {@inheritDoc}
@@ -1116,7 +937,6 @@
     public synchronized Iterable<NodeId> getAllNodeIds(NodeId bigger, int maxCount)
             throws ItemStateException, RepositoryException {
         ResultSet rs = null;
-        BundleDbContext context = createContext();
         try {
             String sql = bundleSelectAllIdsSQL;
             NodeId lowId = null;
@@ -1133,8 +953,7 @@
                 // see also bundleSelectAllIdsFrom SQL statement
                 maxCount += 10;
             }
-            Statement stmt = context.getConnectionHelper().executeStmt(sql, keys, false, maxCount);
-            rs = stmt.getResultSet();
+            rs = conHelper.exec(sql, keys, false, maxCount);
             ArrayList<NodeId> result = new ArrayList<NodeId>();
             while ((maxCount == 0 || result.size() < maxCount) && rs.next()) {
                 NodeId current;
@@ -1159,17 +978,16 @@
             log.error(msg, e);
             throw new ItemStateException(msg, e);
         } finally {
-            closeResultSet(rs);
-            context.closeSilently();
+            DbUtility.close(rs);
         }
     }
 
     /**
      * {@inheritDoc}
      */
-    protected synchronized NodePropBundle loadBundle(NodeId id, Context context)
+    protected synchronized NodePropBundle loadBundle(NodeId id)
             throws ItemStateException {
-        return loadBundle(id, false, (BundleDbContext)context);
+        return loadBundle(id, false);
     }
 
     /**
@@ -1207,13 +1025,12 @@
      *         exist.
      * @throws ItemStateException if an error while loading occurs.
      */
-    protected synchronized NodePropBundle loadBundle(NodeId id, boolean checkBeforeLoading, BundleDbContext context)
+    protected synchronized NodePropBundle loadBundle(NodeId id, boolean checkBeforeLoading)
             throws ItemStateException {
         ResultSet rs = null;
         
         try {
-            Statement stmt = context.getConnectionHelper().executeStmt(bundleSelectSQL, getKey(id));
-            rs = stmt.getResultSet();
+            rs = conHelper.exec(bundleSelectSQL, getKey(id), false, 0);
             if (!rs.next()) {
                 return null;
             }
@@ -1239,19 +1056,17 @@
             log.error(msg);
             throw new ItemStateException(msg, e);
         } finally {
-            closeResultSet(rs);
+            DbUtility.close(rs);
         }
     }
 
     /**
      * {@inheritDoc}
      */
-    protected synchronized boolean existsBundle(NodeId id, Context context) throws ItemStateException {
+    protected synchronized boolean existsBundle(NodeId id) throws ItemStateException {
         ResultSet rs = null;
         try {
-            ConnectionHelper helper = ((BundleDbContext)context).getConnectionHelper();
-            Statement stmt = helper.executeStmt(bundleSelectSQL, getKey(id));
-            rs = stmt.getResultSet();
+            rs = conHelper.exec(bundleSelectSQL, getKey(id), false, 0);
             // a bundle exists, if the result has at least one entry
             return rs.next();
         } catch (Exception e) {
@@ -1259,14 +1074,14 @@
             log.error(msg, e);
             throw new ItemStateException(msg, e);
         } finally {
-            closeResultSet(rs);
+            DbUtility.close(rs);
         }
     }
 
     /**
      * {@inheritDoc}
      */
-    protected synchronized void storeBundle(NodePropBundle bundle, Context context) throws ItemStateException {
+    protected synchronized void storeBundle(NodePropBundle bundle) throws ItemStateException {
         try {
             ByteArrayOutputStream out = new ByteArrayOutputStream(INITIAL_BUFFER_SIZE);
             DataOutputStream dout = new DataOutputStream(out);
@@ -1275,7 +1090,7 @@
 
             String sql = bundle.isNew() ? bundleInsertSQL : bundleUpdateSQL;
             Object[] params = createParams(bundle.getId(), out.toByteArray(), true);
-            ((BundleDbContext)context).getConnectionHelper().executeStmt(sql, params);
+            conHelper.update(sql, params);
         } catch (Exception e) {
             String msg = "failed to write bundle: " + bundle.getId();
             log.error(msg, e);
@@ -1286,10 +1101,9 @@
     /**
      * {@inheritDoc}
      */
-    protected synchronized void destroyBundle(NodePropBundle bundle, Context context) throws ItemStateException {
+    protected synchronized void destroyBundle(NodePropBundle bundle) throws ItemStateException {
         try {
-            ConnectionHelper helper = ((BundleDbContext)context).getConnectionHelper(); 
-            helper.executeStmt(bundleDeleteSQL, getKey(bundle.getId()));
+            conHelper.update(bundleDeleteSQL, getKey(bundle.getId()));
         } catch (Exception e) {
             if (e instanceof NoSuchItemStateException) {
                 throw (NoSuchItemStateException) e;
@@ -1311,11 +1125,8 @@
 
         ResultSet rs = null;
         InputStream in = null;
-        BundleDbContext context = createContext();
         try {
-            Statement stmt = context.getConnectionHelper().executeStmt(
-                    nodeReferenceSelectSQL, getKey(targetId));
-            rs = stmt.getResultSet();
+            rs = conHelper.exec(nodeReferenceSelectSQL, getKey(targetId), false, 0);
             if (!rs.next()) {
                 throw new NoSuchItemStateException(targetId.toString());
             }
@@ -1334,8 +1145,7 @@
             throw new ItemStateException(msg, e);
         } finally {
             IOUtils.closeQuietly(in);
-            closeResultSet(rs);
-            context.closeSilently();
+            DbUtility.close(rs);
         }
     }
 
@@ -1348,7 +1158,7 @@
      * shared statement. If the method would not be synchronized, the shared
      * statement must be synchronized.
      */
-    public synchronized void store(NodeReferences refs, Context context) throws ItemStateException {
+    public synchronized void store(NodeReferences refs) throws ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
@@ -1364,8 +1174,8 @@
             Serializer.serialize(refs, out);
 
             Object[] params = createParams(refs.getTargetId(), out.toByteArray(), true);
-            ((BundleDbContext)context).getConnectionHelper().executeStmt(sql, params);
-
+            conHelper.exec(sql, params);
+            
             // there's no need to close a ByteArrayOutputStream
             //out.close();
         } catch (Exception e) {
@@ -1378,15 +1188,13 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized void destroy(NodeReferences refs, Context context) throws ItemStateException {
+    public synchronized void destroy(NodeReferences refs) throws ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }
 
         try {
-        	ConnectionHelper helper = ((BundleDbContext)context).getConnectionHelper();
-            helper.executeStmt(nodeReferenceDeleteSQL,
-                    getKey(refs.getTargetId()));
+            conHelper.exec(nodeReferenceDeleteSQL, getKey(refs.getTargetId()));
         } catch (Exception e) {
             if (e instanceof NoSuchItemStateException) {
                 throw (NoSuchItemStateException) e;
@@ -1406,12 +1214,8 @@
         }
 
         ResultSet rs = null;
-        BundleDbContext context = createContext();
         try {
-            ConnectionHelper helper = context.getConnectionHelper();
-            Statement stmt = helper.executeStmt(
-                    nodeReferenceSelectSQL, getKey(targetId));
-            rs = stmt.getResultSet();
+            rs = conHelper.exec(nodeReferenceSelectSQL, getKey(targetId), false, 0);
 
             // a reference exists if the result has at least one entry
             return rs.next();
@@ -1421,54 +1225,7 @@
             log.error(msg, e);
             throw new ItemStateException(msg, e);
         } finally {
-            closeResultSet(rs);
-            context.closeSilently();
-        }
-    }
-
-    /**
-     * Resets the given <code>PreparedStatement</code> by clearing the
-     * parameters and warnings contained.
-     *
-     * @param stmt The <code>PreparedStatement</code> to reset. If
-     *             <code>null</code> this method does nothing.
-     */
-    protected synchronized void resetStatement(PreparedStatement stmt) {
-        if (stmt != null) {
-            try {
-                stmt.clearParameters();
-                stmt.clearWarnings();
-            } catch (SQLException se) {
-                logException("Failed resetting PreparedStatement", se);
-            }
-        }
-    }
-
-    /**
-     * Closes the result set
-     * @param rs the result set
-     */
-    protected void closeResultSet(ResultSet rs) {
-        if (rs != null) {
-            try {
-                rs.close();
-            } catch (SQLException se) {
-                logException("Failed closing ResultSet", se);
-            }
-        }
-    }
-
-    /**
-     * closes the statement
-     * @param stmt the statement
-     */
-    protected void closeStatement(PreparedStatement stmt) {
-        if (stmt != null) {
-            try {
-                stmt.close();
-            } catch (SQLException se) {
-                logException("Failed closing PreparedStatement", se);
-            }
+            DbUtility.close(rs);
         }
     }
 
@@ -1609,46 +1366,40 @@
          * {@inheritDoc}
          */
         public InputStream get(String blobId) throws Exception {
-        	final BundleDbContext context = createContext();
-        	try
-        	{
-        		Statement stmt = context.getConnectionHelper().executeStmt(blobSelectSQL, new Object[]{blobId});
-        	        	
-        		final ResultSet rs = stmt.getResultSet();
-        		if (!rs.next()) {
-        			closeResultSet(rs);
-        			throw new Exception("no such BLOB: " + blobId);
-        		}
-        		
+            ResultSet rs = null;
+            boolean close = true;
+            try {
+                rs = conHelper.exec(blobSelectSQL, new Object[]{blobId}, false, 0);
+                if (!rs.next()) {
+                    throw new Exception("no such BLOB: " + blobId);
+                }
+
                 InputStream in = rs.getBinaryStream(1);
                 if (in == null) {
                     // some databases treat zero-length values as NULL;
                     // return empty InputStream in such a case
-                    closeResultSet(rs);
-                    context.closeSilently();
                     return new ByteArrayInputStream(new byte[0]);
                 }
 
-                /**
-                 * return an InputStream wrapper in order to
-                 * close the ResultSet when the stream is closed
-                 */
+                 // return an InputStream wrapper in order to close the ResultSet when the stream is closed
+                close = false;
+                final ResultSet rs2 = rs;
                 return new FilterInputStream(in) {
+
                     public void close() throws IOException {
-                    	try {
-                    		in.close();
-                    		// now it's safe to close ResultSet
-                    		closeResultSet(rs);
-                    	} finally {
-                    		context.closeSilently();
-                    	}
+                        try {
+                            in.close();
+                        } finally {
+                            // now it's safe to close ResultSet
+                            DbUtility.close(rs2);
+                        }
                     }
                 };
-
-        	} catch (Exception e) 	{
-        		context.closeSilently();
-        		throw (e);
-        	}
+            } finally {
+                if (close) {
+                    DbUtility.close(rs);
+                }
+            }
         }
 
         /**
@@ -1656,33 +1407,25 @@
          */
         public synchronized void put(String blobId, InputStream in, long size)
                 throws Exception {
-        	BundleDbContext context = createContext();
+            ResultSet rs = null;
+            boolean exists;
         	try {
-	            Statement stmt = context.getConnectionHelper().executeStmt(blobSelectExistSQL, new Object[]{blobId});
-	            ResultSet rs = stmt.getResultSet();
+	            rs = conHelper.exec(blobSelectExistSQL, new Object[]{blobId}, false, 0);
 	            // a BLOB exists if the result has at least one entry
-	            boolean exists = rs.next();
-	            closeResultSet(rs);
-	
-	            String sql = (exists) ? blobUpdateSQL : blobInsertSQL;
-	            Object[] params = new Object[]{new StreamWrapper(in, size), blobId};
-	            context.getConnectionHelper().executeStmt(sql, params);
+	            exists = rs.next();
         	} finally {
-        		context.closeSilently();
+	            DbUtility.close(rs);
         	}
+            String sql = (exists) ? blobUpdateSQL : blobInsertSQL;
+            Object[] params = new Object[]{new StreamWrapper(in, size), blobId};
+            conHelper.exec(sql, params);
         }
 
         /**
          * {@inheritDoc}
          */
         public synchronized boolean remove(String blobId) throws Exception {
-        	BundleDbContext context = createContext();
-        	try {
-        		Statement stmt = context.getConnectionHelper().executeStmt(blobDeleteSQL, new Object[]{blobId});
-        		return stmt.getUpdateCount() == 1;
-        	} finally {
-        		context.closeSilently();
-        	}
+            return conHelper.update(blobDeleteSQL, new Object[]{blobId}) == 1;
         }
 
         public void close() {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java?rev=801659&r1=801658&r2=801659&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java Thu Aug  6 14:27:22 2009
@@ -99,15 +99,6 @@
      * the name of this persistence manager
      */
     private String name = super.toString();
-   
-    protected Context createContext() {
-    	return new Context() {
-    		@Override
-    		void closeSilently() {
-    			
-    		}
-    	};
-    }
 
     /**
      * Returns the configured block size of the blob cqfs
@@ -240,7 +231,7 @@
     /**
      * {@inheritDoc}
      */
-    protected synchronized NodePropBundle loadBundle(NodeId id, Context context)
+    protected synchronized NodePropBundle loadBundle(NodeId id)
             throws ItemStateException {
         DataInputStream din = null;
         try {
@@ -266,7 +257,7 @@
     /**
      * {@inheritDoc}
      */
-    protected synchronized boolean existsBundle(NodeId id, Context context) throws ItemStateException {
+    protected synchronized boolean existsBundle(NodeId id) throws ItemStateException {
         try {
             StringBuffer buf = buildNodeFilePath(null, id);
             return itemFs.exists(buf.toString());
@@ -317,7 +308,7 @@
     /**
      * {@inheritDoc}
      */
-    protected synchronized void storeBundle(NodePropBundle bundle, Context context) throws ItemStateException {
+    protected synchronized void storeBundle(NodePropBundle bundle) throws ItemStateException {
         try {
             StringBuffer buf = buildNodeFolderPath(null, bundle.getId());
             buf.append('.');
@@ -341,7 +332,7 @@
     /**
      * {@inheritDoc}
      */
-    protected synchronized void destroyBundle(NodePropBundle bundle, Context context) throws ItemStateException {
+    protected synchronized void destroyBundle(NodePropBundle bundle) throws ItemStateException {
         try {
             StringBuffer buf = buildNodeFilePath(null, bundle.getId());
             itemFs.deleteFile(buf.toString());
@@ -388,7 +379,7 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized void store(NodeReferences refs, Context context)
+    public synchronized void store(NodeReferences refs)
             throws ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
@@ -415,7 +406,7 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized void destroy(NodeReferences refs, Context context) throws ItemStateException {
+    public synchronized void destroy(NodeReferences refs) throws ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
         }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/DerbyPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/DerbyPersistenceManager.java?rev=801659&r1=801658&r2=801659&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/DerbyPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/DerbyPersistenceManager.java Thu Aug  6 14:27:22 2009
@@ -16,17 +16,14 @@
  */
 package org.apache.jackrabbit.core.persistence.bundle;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.jackrabbit.core.persistence.PMContext;
 import org.apache.jackrabbit.core.persistence.bundle.util.ConnectionHelper;
+import org.apache.jackrabbit.core.persistence.bundle.util.DerbyConnectionHelper;
 
 import java.sql.Connection;
-import java.sql.DriverManager;
 import java.sql.SQLException;
-import java.sql.Statement;
 
-import javax.jcr.RepositoryException;
+import javax.sql.DataSource;
 
 /**
  * Extends the {@link BundleDbPersistenceManager} by derby specific code.
@@ -56,9 +53,6 @@
     /** name of the embedded driver */
     public static final String DERBY_EMBEDDED_DRIVER = "org.apache.derby.jdbc.EmbeddedDriver";
 
-    /** the default logger */
-    private static Logger log = LoggerFactory.getLogger(DerbyPersistenceManager.class);
-
     /** @see #setDerbyStorageInitialPages(String) */
     private int derbyStorageInitialPages = 16;
 
@@ -254,39 +248,29 @@
             setSchemaObjectPrefix("");
         }
         super.init(context);
+        // set properties       
+        if (DERBY_EMBEDDED_DRIVER.equals(getDriver())) {
+            conHelper.exec("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY "
+                    + "('derby.storage.initialPages', '" + derbyStorageInitialPages + "')");
+            conHelper.exec("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY "
+                    + "('derby.storage.minimumRecordSize', '" + derbyStorageMinimumRecordSize + "')");
+            conHelper.exec("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY "
+                    + "('derby.storage.pageCacheSize', '" + derbyStoragePageCacheSize + "')");
+            conHelper.exec("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY "
+                    + "('derby.storage.pageReservedSpace', '" + derbyStoragePageReservedSpace + "')");
+            conHelper.exec("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY " + "('derby.storage.pageSize', '"
+                    + derbyStoragePageSize + "')");
+        }
     }
 
     /**
      * {@inheritDoc}
      */
-    protected void checkSchema() throws SQLException, RepositoryException {    	
-        // set properties    	
-        if (DERBY_EMBEDDED_DRIVER.equals(getDriver())) {
-        	Connection connection = null;        	
-            Statement stmt = null;
-            try {
-            	connection = dataSource.getConnection();
-            	stmt = connection.createStatement();
-                stmt.execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY "
-                        + "('derby.storage.initialPages', '" + derbyStorageInitialPages + "')");
-                stmt.execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY "
-                        + "('derby.storage.minimumRecordSize', '" + derbyStorageMinimumRecordSize + "')");
-                stmt.execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY "
-                        + "('derby.storage.pageCacheSize', '" + derbyStoragePageCacheSize + "')");
-                stmt.execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY "
-                        + "('derby.storage.pageReservedSpace', '" + derbyStoragePageReservedSpace + "')");
-                stmt.execute("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY "
-                        + "('derby.storage.pageSize', '" + derbyStoragePageSize + "')");
-
-            } finally {
-                ConnectionHelper.closeSilently(stmt);
-                ConnectionHelper.closeSilently(connection);
-            }
-        }
-        super.checkSchema();
+    @Override
+    protected ConnectionHelper createConnectionHelper(DataSource dataSrc) {
+        return new DerbyConnectionHelper(dataSrc);
     }
 
-
     /**
      * {@inheritDoc}
      *
@@ -306,44 +290,8 @@
      * @see DatabasePersistenceManager#closeConnection(Connection)
      */
     public void close() throws Exception {
-        // check for embedded driver
-        if (!DERBY_EMBEDDED_DRIVER.equals(getDriver())) {
-            return;
-        }
-
-        // prepare connection url for issuing shutdown command
-        String url = null;
-        Connection connection = null;
-        
-        try {
-        	connection = dataSource.getConnection();
-        	url = connection.getMetaData().getURL();
-        	
-            // we have to reset the connection to 'autoCommit=true' before closing it;
-            // otherwise Derby would mysteriously complain about some pending uncommitted
-            // changes which can't possibly be true.
-            // @todo further investigate
-        	connection.setAutoCommit(true);
-        }
-        finally {
-        	ConnectionHelper.closeSilently(connection);
-        }
-        int pos = url.lastIndexOf(';');
-        if (pos != -1) {
-            // strip any attributes from connection url
-            url = url.substring(0, pos);
-        }
-        url += ";shutdown=true";
-
         super.close();
-
-        // now it's safe to shutdown the embedded Derby database
-        try {
-            DriverManager.getConnection(url);
-        } catch (SQLException e) {
-            // a shutdown command always raises a SQLException
-            log.info(e.getMessage());
-        }
+        ((DerbyConnectionHelper) conHelper).shutDown(getDriver());
     }
 
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/H2PersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/H2PersistenceManager.java?rev=801659&r1=801658&r2=801659&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/H2PersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/H2PersistenceManager.java Thu Aug  6 14:27:22 2009
@@ -97,18 +97,19 @@
      * {@inheritDoc}
      */
     protected void checkSchema() throws SQLException, RepositoryException {
-    	Connection connection = null;
-        Statement stmt = null;
-        
-        try {
-        	connection = dataSource.getConnection();
-        	stmt = connection.createStatement();
-            stmt.execute("SET LOCK_TIMEOUT " + lockTimeout);
-        } finally {
-            ConnectionHelper.closeSilently(stmt);
-            ConnectionHelper.closeSilently(connection);
-        }
-        super.checkSchema();
+        // FIXME
+//    	Connection connection = null;
+//        Statement stmt = null;
+//        
+//        try {
+//        	connection = dataSource.getConnection();
+//        	stmt = connection.createStatement();
+//            stmt.execute("SET LOCK_TIMEOUT " + lockTimeout);
+//        } finally {
+//            ConnectionHelper.closeSilently(stmt);
+//            ConnectionHelper.closeSilently(connection);
+//        }
+//        super.checkSchema();
     }
 
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/MSSqlPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/MSSqlPersistenceManager.java?rev=801659&r1=801658&r2=801659&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/MSSqlPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/MSSqlPersistenceManager.java Thu Aug  6 14:27:22 2009
@@ -46,9 +46,12 @@
         setDatabaseType("mssql");
     }
 
-    protected String createSchemaSQL(String sql) {
-        return Text.replace(
-                super.createSchemaSQL(sql), "${tableSpace}", tableSpace);
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String createSchemaSQL(String sql) {
+        return Text.replace(super.createSchemaSQL(sql), "${tableSpace}", tableSpace);
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java?rev=801659&r1=801658&r2=801659&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/Oracle9PersistenceManager.java Thu Aug  6 14:27:22 2009
@@ -21,6 +21,7 @@
 import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.persistence.PMContext;
 import org.apache.jackrabbit.core.persistence.bundle.util.ConnectionHelper;
+import org.apache.jackrabbit.core.persistence.bundle.util.DbUtility;
 import org.apache.jackrabbit.core.persistence.bundle.util.NodePropBundle;
 import org.apache.jackrabbit.core.persistence.util.Serializer;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -89,13 +90,14 @@
 
         // use the Connection object for using the exact same
         // class loader that the Oracle driver was loaded with
-        Connection connection = null;
-        try {
-        	connection = dataSource.getConnection();
-        	blobClass = connection.getClass().getClassLoader().loadClass("oracle.sql.BLOB");
-        } finally {
-        	ConnectionHelper.closeSilently(connection);
-        }
+// FIXME        
+//        Connection connection = null;
+//        try {
+//        	connection = dataSource.getConnection();
+//        	blobClass = connection.getClass().getClassLoader().loadClass("oracle.sql.BLOB");
+//        } finally {
+//        	ConnectionHelper.closeSilently(connection);
+//        }
         
         duractionSessionConstant =
                 new Integer(blobClass.getField("DURATION_SESSION").getInt(null));
@@ -111,9 +113,9 @@
     }
 
     /**
-     * @inheritDoc
+     * {@inheritDoc}
      */
-    protected synchronized void storeBundle(NodePropBundle bundle, Context context)
+    protected synchronized void storeBundle(NodePropBundle bundle)
             throws ItemStateException {
         Blob blob = null;        
         try {
@@ -123,9 +125,9 @@
             dout.close();
 
             String sql = bundle.isNew() ? bundleInsertSQL : bundleUpdateSQL;
-            blob = createTemporaryBlob(new ByteArrayInputStream(out.toByteArray()), (BundleDbContext)context);
+            blob = createTemporaryBlob(new ByteArrayInputStream(out.toByteArray()));
             Object[] params = createParams(bundle.getId(), blob, true);
-            ((BundleDbContext)context).getConnectionHelper().executeStmt(sql, params);
+            conHelper.exec(sql, params);
         } catch (Exception e) {
             String msg = "failed to write bundle: " + bundle.getId();
             log.error(msg, e);
@@ -141,9 +143,10 @@
     }
 
     /**
-     * @inheritDoc
+     * {@inheritDoc}
      */
-    public synchronized void store(NodeReferences refs, Context context)
+    @Override
+    public synchronized void store(NodeReferences refs)
             throws ItemStateException {
         if (!initialized) {
             throw new IllegalStateException("not initialized");
@@ -162,9 +165,9 @@
             // we are synchronized on this instance, therefore we do not
             // not have to additionally synchronize on the preparedStatement
 
-            blob = createTemporaryBlob(new ByteArrayInputStream(out.toByteArray()), (BundleDbContext) context);
+            blob = createTemporaryBlob(new ByteArrayInputStream(out.toByteArray()));
             Object[] params = createParams(refs.getTargetId(), blob, true);
-            ((BundleDbContext)context).getConnectionHelper().executeStmt(sql, params);
+            conHelper.exec(sql, params);
 
             // there's no need to close a ByteArrayOutputStream
             //out.close();
@@ -187,7 +190,7 @@
      * Creates a temporary oracle.sql.BLOB instance via reflection and spools
      * the contents of the specified stream.
      */
-    protected Blob createTemporaryBlob(InputStream in, BundleDbContext context) throws Exception {
+    protected Blob createTemporaryBlob(InputStream in) throws Exception {
         /*
         BLOB blob = BLOB.createTemporary(con, false, BLOB.DURATION_SESSION);
         blob.open(BLOB.MODE_READWRITE);
@@ -198,27 +201,28 @@
         blob.close();
         return blob;
         */
-    	
-        Method createTemporary = blobClass.getMethod("createTemporary",
-                new Class[]{Connection.class, Boolean.TYPE, Integer.TYPE});
-        Object blob = createTemporary.invoke(null,
-                new Object[]{context.getConnection(), Boolean.FALSE, duractionSessionConstant});
-        Method open = blobClass.getMethod("open", new Class[]{Integer.TYPE});
-        open.invoke(blob, new Object[]{modeReadWriteConstant});
-        Method getBinaryOutputStream = blobClass.getMethod("getBinaryOutputStream", new Class[0]);
-        OutputStream out = (OutputStream) getBinaryOutputStream.invoke(blob);
-        try {
-            IOUtils.copy(in, out);
-        } finally {
-            try {
-                out.flush();
-            } catch (IOException ioe) {
-            }
-            out.close();
-        }
-        Method close = blobClass.getMethod("close", new Class[0]);
-        close.invoke(blob);
-        return (Blob) blob;
+// FIXME
+//        Method createTemporary = blobClass.getMethod("createTemporary",
+//                new Class[]{Connection.class, Boolean.TYPE, Integer.TYPE});
+//        Object blob = createTemporary.invoke(null,
+//                new Object[]{context.getConnection(), Boolean.FALSE, duractionSessionConstant});
+//        Method open = blobClass.getMethod("open", new Class[]{Integer.TYPE});
+//        open.invoke(blob, new Object[]{modeReadWriteConstant});
+//        Method getBinaryOutputStream = blobClass.getMethod("getBinaryOutputStream", new Class[0]);
+//        OutputStream out = (OutputStream) getBinaryOutputStream.invoke(blob);
+//        try {
+//            IOUtils.copy(in, out);
+//        } finally {
+//            try {
+//                out.flush();
+//            } catch (IOException ioe) {
+//            }
+//            out.close();
+//        }
+//        Method close = blobClass.getMethod("close", new Class[0]);
+//        close.invoke(blob);
+//        return (Blob) blob;
+        return null;
     }
 
     /**
@@ -245,17 +249,20 @@
                 throws Exception {
 
             Blob blob = null;
-            BundleDbContext context = createContext();
             try {
-                Statement stmt = context.getConnectionHelper().executeStmt(blobSelectExistSQL, new Object[]{blobId});
-                ResultSet rs = stmt.getResultSet();
-                // a BLOB exists if the result has at least one entry
-                boolean exists = rs.next();
-                closeResultSet(rs);
+                boolean exists = false;
+                ResultSet rs = null;
+                try {
+                    conHelper.exec(blobSelectExistSQL, new Object[]{blobId}, false, 0);
+                    // a BLOB exists if the result has at least one entry
+                    exists = rs.next();
+                } finally {
+                    DbUtility.close(rs);
+                }
 
                 String sql = (exists) ? blobUpdateSQL : blobInsertSQL;
-                blob = createTemporaryBlob(in, context);
-                context.getConnectionHelper().executeStmt(sql, new Object[]{blob, blobId});
+                blob = createTemporaryBlob(in);
+                conHelper.exec(sql, new Object[]{blob, blobId});
             } finally {
                 if (blob != null) {
                     try {
@@ -263,7 +270,6 @@
                     } catch (Exception e) {
                     }
                 }
-                context.closeSilently();
             }
         }
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/OraclePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/OraclePersistenceManager.java?rev=801659&r1=801658&r2=801659&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/OraclePersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/OraclePersistenceManager.java Thu Aug  6 14:27:22 2009
@@ -106,21 +106,22 @@
         super.init(context);
 
         // check driver version
-        Connection connection = dataSource.getConnection();
-        try {
-            DatabaseMetaData metaData = connection.getMetaData();
-            if (metaData.getDriverMajorVersion() < 10) {
-                // Oracle drivers prior to version 10 only support
-                // writing BLOBs up to 32k in size...
-                log.warn("Unsupported driver version detected: "
-                        + metaData.getDriverName()
-                        + " v" + metaData.getDriverVersion());
-            }
-        } catch (SQLException e) {
-            log.warn("Can not retrieve driver version", e);
-        } finally {
-        	ConnectionHelper.closeSilently(connection);
-        }
+        // FIXME
+//        Connection connection = dataSource.getConnection();
+//        try {
+//            DatabaseMetaData metaData = connection.getMetaData();
+//            if (metaData.getDriverMajorVersion() < 10) {
+//                // Oracle drivers prior to version 10 only support
+//                // writing BLOBs up to 32k in size...
+//                log.warn("Unsupported driver version detected: "
+//                        + metaData.getDriverName()
+//                        + " v" + metaData.getDriverVersion());
+//            }
+//        } catch (SQLException e) {
+//            log.warn("Can not retrieve driver version", e);
+//        } finally {
+//        	ConnectionHelper.closeSilently(connection);
+//        }
     }
 
     /**
@@ -128,24 +129,26 @@
      * @return a new instance of a NGKDbNameIndex.
      * @throws SQLException if an SQL error occurs.
      */
-    protected DbNameIndex createDbNameIndex() throws SQLException {
-        return new NGKDbNameIndex(dataSource, schemaObjectPrefix);
-    }
+// FIXME
+//    protected DbNameIndex createDbNameIndex() throws SQLException {
+//        return new NGKDbNameIndex(dataSource, schemaObjectPrefix);
+//    }
 
     /**
      * {@inheritDoc}
      *
      * @return <code>true</code>
      */
-    protected boolean checkTablesWithUser() {
+    @Override
+    public boolean checkTablesWithUser() {
         return true;
     }
 
     /**
      * {@inheritDoc}
      */
-    protected String createSchemaSQL(String sql) {
-        sql = Text.replace(sql, SCHEMA_OBJECT_PREFIX_VARIABLE, schemaObjectPrefix).trim();
+    @Override
+    public String createSchemaSQL(String sql) {
         // set the tablespace if it is defined
         String tspace;
         if (tableSpace == null || "".equals(tableSpace)) {
@@ -153,7 +156,7 @@
         } else {
             tspace = "tablespace " + tableSpace;
         }
-        return Text.replace(sql, TABLE_SPACE_VARIABLE, tspace).trim();
+        return Text.replace(super.createSchemaSQL(sql), TABLE_SPACE_VARIABLE, tspace).trim();
     }
 
     /**
@@ -163,29 +166,30 @@
      *
      * @inheritDoc
      */
-    protected void prepareSchemaObjectPrefix() throws Exception {
-        String legalChars;
-        Connection connection = null;
-        try {
-        	connection = dataSource.getConnection();
-        	DatabaseMetaData metaData = connection.getMetaData();
-        	legalChars = metaData.getExtraNameCharacters();
-        } finally {
-        	ConnectionHelper.closeSilently(connection);
-        }        	
-        
-        legalChars += "ABCDEFGHIJKLMNOPQRSTUVWXZY0123456789_";
-
-        String prefix = schemaObjectPrefix.toUpperCase();
-        StringBuffer escaped = new StringBuffer();
-        for (int i = 0; i < prefix.length(); i++) {
-            char c = prefix.charAt(i);
-            if (legalChars.indexOf(c) == -1) {
-                escaped.append('_');
-            } else {
-                escaped.append(c);
-            }
-        }
-        schemaObjectPrefix = escaped.toString();
-    }
+// FIXME
+//    protected void prepareSchemaObjectPrefix() throws Exception {
+//        String legalChars;
+//        Connection connection = null;
+//        try {
+//        	connection = dataSource.getConnection();
+//        	DatabaseMetaData metaData = connection.getMetaData();
+//        	legalChars = metaData.getExtraNameCharacters();
+//        } finally {
+//        	ConnectionHelper.closeSilently(connection);
+//        }        	
+//        
+//        legalChars += "ABCDEFGHIJKLMNOPQRSTUVWXZY0123456789_";
+//
+//        String prefix = schemaObjectPrefix.toUpperCase();
+//        StringBuffer escaped = new StringBuffer();
+//        for (int i = 0; i < prefix.length(); i++) {
+//            char c = prefix.charAt(i);
+//            if (legalChars.indexOf(c) == -1) {
+//                escaped.append('_');
+//            } else {
+//                escaped.append(c);
+//            }
+//        }
+//        schemaObjectPrefix = escaped.toString();
+//    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/PostgreSQLPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/PostgreSQLPersistenceManager.java?rev=801659&r1=801658&r2=801659&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/PostgreSQLPersistenceManager.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/PostgreSQLPersistenceManager.java Thu Aug  6 14:27:22 2009
@@ -76,9 +76,10 @@
      * @return a new instance of a DbNameIndex.
      * @throws java.sql.SQLException if an SQL error occurs.
      */
-    protected DbNameIndex createDbNameIndex() throws SQLException {
-        return new PostgreSQLNameIndex(dataSource, schemaObjectPrefix);
-    }
+// FIXME
+//    protected DbNameIndex createDbNameIndex() throws SQLException {
+//        return new PostgreSQLNameIndex(dataSource, schemaObjectPrefix);
+//    }
 
     /**
      * returns the storage model
@@ -88,37 +89,39 @@
         return SM_LONGLONG_KEYS;
     }
 
-    protected synchronized NodePropBundle loadBundle(NodeId id)
-            throws ItemStateException {
-    	BundleDbContext context = createContext();
-        try {        	
-            Statement stmt = context.getConnectionHelper().executeStmt(bundleSelectSQL, getKey(id));
-            ResultSet rs = stmt.getResultSet();
-            try {
-                if (rs.next()) {
-                    InputStream input = rs.getBinaryStream(1);
-                    try {
-                        TrackingInputStream cin = new TrackingInputStream(input);
-                        DataInputStream din = new DataInputStream(cin);
-                        NodePropBundle bundle = binding.readBundle(din, id);
-                        bundle.setSize(cin.getPosition());
-                        return bundle;
-                    } finally {
-                        input.close();
-                    }
-                } else {
-                    return null;
-                }
-            } finally {
-                rs.close();
-            }
-        } catch (Exception e) {
-            String msg = "failed to read bundle: " + id + ": " + e;
-            log.error(msg);
-            throw new ItemStateException(msg, e);
-        } finally {
-        	context.closeSilently();
-        }
-    }
+ // FIXME
+//
+//    protected synchronized NodePropBundle loadBundle(NodeId id)
+//            throws ItemStateException {
+//    	BundleDbContext context = createContext();
+//        try {        	
+//            Statement stmt = context.getConnectionHelper().executeStmt(bundleSelectSQL, getKey(id));
+//            ResultSet rs = stmt.getResultSet();
+//            try {
+//                if (rs.next()) {
+//                    InputStream input = rs.getBinaryStream(1);
+//                    try {
+//                        TrackingInputStream cin = new TrackingInputStream(input);
+//                        DataInputStream din = new DataInputStream(cin);
+//                        NodePropBundle bundle = binding.readBundle(din, id);
+//                        bundle.setSize(cin.getPosition());
+//                        return bundle;
+//                    } finally {
+//                        input.close();
+//                    }
+//                } else {
+//                    return null;
+//                }
+//            } finally {
+//                rs.close();
+//            }
+//        } catch (Exception e) {
+//            String msg = "failed to read bundle: " + id + ": " + e;
+//            log.error(msg);
+//            throw new ItemStateException(msg, e);
+//        } finally {
+//        	context.closeSilently();
+//        }
+//    }
 
 }



Mime
View raw message