You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ma...@apache.org on 2009/08/06 16:27:23 UTC

svn commit: r801659 [2/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...

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionHelper.java?rev=801659&r1=801658&r2=801659&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionHelper.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ConnectionHelper.java Thu Aug  6 14:27:22 2009
@@ -16,217 +16,359 @@
  */
 package org.apache.jackrabbit.core.persistence.bundle.util;
 
+import java.io.BufferedReader;
+import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 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 javax.jcr.RepositoryException;
+import javax.sql.DataSource;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.core.persistence.bundle.BundleDbPersistenceManager;
 
 /**
  * This class provides convenience methods to execute SQL statements.
+ * 
+ * Responsibilities of this class.
+ * <ul>
+ * <li>Provide a means to execute SQL statements in isolation.</li>
+ * <li>Provide a means to execute a JDBC transaction.</li>
+ * </ul>
+ * This class has two states: it is either in <i>batch mode</i> or it is not. Batch mode affects three
+ * methods:
+ * 
+ * <p/>
+ * 
+ * Behavior on an {@code SQLException} on the {@link #exec(String, Object[])},
+ * {@link #exec(String, Object[], boolean, int)} and {@link #update(String, Object[])} methods is as follows:
+ * <ul>
+ * <li>If a batch is in progress then the {@code SQLException} is thrown.
+ * <li>If in non-batch mode, then the {@code SQLException} is caught and the SQL statement is re-executed once
+ * with a new connection from the {@link DataSource}.</li>
+ * </ul>
+ * 
+ * TODO: retry if exec fails in non-batch mode (last bullet above)
  */
 public class ConnectionHelper {
 
-	private final Connection connection;
-	
+    protected final DataSource dataSource;
+
+    private boolean inBatchMode = false;
+
+    private Connection batchConnection = null;
+
+    /**
+     * Constructor.
+     * 
+     * @param dataSrc the {@link DataSource} on which this instance acts
+     */
+    public ConnectionHelper(DataSource dataSrc) {
+        dataSource = dataSrc;
+    }
+
     /**
-     * Creates a new {@link ConnectionHelper} instance
-     *
-     * @param connection
+     * A utility method that makes sure that <code>identifier</code> does only consist of characters that are
+     * allowed in names on the target database. Illegal characters will be escaped as necessary.
+     * 
+     * @param identifier the identifier to convert to a db specific identifier
+     * @return the db-normalized form of the given identifier
+     * @throws SQLException if an error occurs
      */
-    public ConnectionHelper(Connection connection) 
-    {
-    	this.connection = connection;
+    public final String prepareDbIdentifier(String identifier) throws SQLException {
+        if (identifier == null) {
+            return null;
+        }
+        String legalChars = "ABCDEFGHIJKLMNOPQRSTUVWXZY0123456789_";
+        legalChars += getExtraNameCharacters();
+        String id = identifier.toUpperCase();
+        StringBuffer escaped = new StringBuffer();
+        for (int i = 0; i < id.length(); i++) {
+            char c = id.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);
+            }
+        }
+        return escaped.toString();
     }
 
     /**
-     * Executes the given SQL query. Retries once or blocks (when the
-     * <code>block</code> parameter has been set to true on construction)
-     * if this fails and autoReconnect is enabled.
-     *
-     * @param sql the SQL query to execute
-     * @return the executed ResultSet
+     * The default implementation returns the {@code extraNameCharacters} provided by the
+     * databases metadata.
+     * 
+     * @return the additional characters for identifiers supported by the db
      * @throws SQLException on error
-     * @throws RepositoryException if the database driver could not be loaded
      */
-    public synchronized ResultSet executeQuery(String sql) throws SQLException, RepositoryException {
-        return executeQueryInternal(sql);
+    protected String getExtraNameCharacters() throws SQLException {
+        Connection con = dataSource.getConnection();
+        try {
+            DatabaseMetaData metaData = con.getMetaData();
+            return metaData.getExtraNameCharacters();
+        } finally {
+            DbUtility.close(con, null, null);
+        }
     }
 
     /**
-     * Executes the given SQL query.
-     *
-     * @param sql query to execute
-     * @return a <code>ResultSet</code> object
+     * Checks if the required schema objects exist and creates them if they don't exist yet.
+     * 
+     * @param ddlStream the stream of the DDL to use to create the schema if necessary (closed by this method)
+     * @param tableName the name of the table to use for the schema-existence-check
+     * @param pm the associated {@link BundleDbPersistenceManager}
      * @throws SQLException if an error occurs
-     * @throws RepositoryException if the database driver could not be loaded
+     * @throws IOException if an error occurs
      */
-    private ResultSet executeQueryInternal(String sql) throws SQLException, RepositoryException {
-        PreparedStatement stmt = null;
+    public final void checkSchema(InputStream ddlStream, String tableName, BundleDbPersistenceManager pm)
+            throws SQLException, IOException {
+        String userName = pm.checkTablesWithUser() ? pm.getUser() : null;
+        if (!tableExists(userName, tableName)) {
+            BufferedReader reader = new BufferedReader(new InputStreamReader(ddlStream));
+            try {
+                String sql = reader.readLine();
+                while (sql != null) {
+                    // Skip comments and empty lines
+                    if (!sql.startsWith("#") && sql.length() > 0) {
+                        // replace prefix variable
+                        sql = pm.createSchemaSQL(sql);
+                        // execute sql stmt
+                        exec(sql);
+                    }
+                    // read next sql stmt
+                    sql = reader.readLine();
+                }
+            } finally {
+                IOUtils.closeQuietly(ddlStream);
+            }
+        }
+    }
+
+    /**
+     * Checks whether the given table exists in the database. The {@code schemaPattern} is used at least on
+     * Oracle databases and should then be equal to the user who owns the table.
+     * 
+     * @param schemaPattern the schema pattern, may be null
+     * @param tableName the name of the table
+     * @return whether the given table exists
+     * @throws SQLException on error
+     */
+    private boolean tableExists(String schemaPattern, String tableName) throws SQLException {
+        Connection con = dataSource.getConnection();
+        ResultSet rs = null;
+        boolean schemaExists = false;
+        String name = tableName;
+        try {
+            DatabaseMetaData metaData = con.getMetaData();
+            if (metaData.storesLowerCaseIdentifiers()) {
+                name = tableName.toLowerCase();
+            } else if (metaData.storesUpperCaseIdentifiers()) {
+                name = tableName.toUpperCase();
+            }
+            rs = metaData.getTables(null, schemaPattern, name, null);
+            schemaExists = rs.next();
+        } finally {
+            DbUtility.close(con, null, rs);
+        }
+        return schemaExists;
+    }
+
+    /**
+     * Starts the batch mode. If an {@link SQLException} is thrown, then the batch mode is not started. <p/>
+     * Important: clients that call this method must make sure that {@link #endBatch(boolean)} is called
+     * eventually.
+     * 
+     * @throws SQLException on error
+     */
+    public final void startBatch() throws SQLException {
+        if (inBatchMode) {
+            throw new IllegalStateException("already in batch mode");
+        }
+        // Invariant: inBatchMode == false && batchConnection == null
         try {
-            stmt = connection.prepareStatement(sql);            
-            return stmt.executeQuery();
+            batchConnection = getConnection();
+            batchConnection.setAutoCommit(false);
+            inBatchMode = true;
         } catch (SQLException e) {
-            logException("could not execute statement", e);
+            // Strive for failure atomicity
+            if (batchConnection != null) {
+                DbUtility.close(batchConnection, null, null);
+            }
+            batchConnection = null;
             throw e;
-        } finally {
-            resetStatement(stmt);
         }
     }
 
     /**
-     * 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.
+     * This method always ends the batch mode.
+     * 
+     * @param commit whether the changes in the batch should be committed or rolled back
+     * @throws SQLException on error
      */
-    private void resetStatement(PreparedStatement stmt) {
-        if (stmt != null) {
-            try {
-                stmt.clearParameters();
-                stmt.clearWarnings();
-            } catch (SQLException se) {
-                logException("Failed resetting PreparedStatement", se);
+    public final void endBatch(boolean commit) throws SQLException {
+        if (!inBatchMode) {
+            throw new IllegalStateException("not in batch mode");
+        }
+        // Invariant: inBatchMode == true && batchConnection != null
+        try {
+            if (commit) {
+                batchConnection.commit();
+            } else {
+                batchConnection.rollback();
             }
+        } finally {
+            DbUtility.close(batchConnection, null, null);
+            batchConnection = null;
+            inBatchMode = false;
         }
     }
 
     /**
-     * Executes the given SQL statement with the specified parameters.
-     *
-     * @param sql statement to execute
-     * @param params parameters to set
-     * @return the <code>Statement</code> object that had been executed
-     * @throws SQLException if an error occurs
-     * @throws RepositoryException if the database driver could not be loaded
+     * Executes a general SQL statement and immediately closes all resources.
+     * 
+     * @param sql an SQL statement string
+     * @param params the parameters for the SQL statement
+     * @throws SQLException on error
      */
-    public PreparedStatement executeStmt(String sql, Object[] params)
-            throws SQLException, RepositoryException {
-        return executeStmt(sql, params, false, 0);
+    public final void exec(String sql, Object...params) throws SQLException {
+        Connection con = null;
+        PreparedStatement stmt = null;
+        try {
+            con = getConnection();
+            stmt = con.prepareStatement(sql);
+            execute(stmt, params);
+        } finally {
+            closeResources(con, stmt, null);
+        }
     }
 
     /**
-     * Executes the given SQL statement with the specified parameters.
-     *
-     * @param sql statement to execute
-     * @param params parameters to set
-     * @param returnGeneratedKeys if the statement should return auto generated keys
-     * @param maxRows the maximum number of rows to return (0 for all rows)
-     * @return the <code>Statement</code> object that had been executed
-     * @throws SQLException if an error occurs
-     * @throws RepositoryException if the database driver could not be loaded
+     * Executes an update or delete statement and returns the update count.
+     * 
+     * @param sql an SQL statement string
+     * @param params the parameters for the SQL statement
+     * @return the update count
+     * @throws SQLException on error
      */
-    public synchronized PreparedStatement executeStmt(
-            String sql, Object[] params, boolean returnGeneratedKeys, int maxRows)
-            throws SQLException, RepositoryException {
-        return executeStmtInternal(sql, params, returnGeneratedKeys, maxRows);
+    public final int update(String sql, Object[] params) throws SQLException {
+        Connection con = null;
+        PreparedStatement stmt = null;
+        try {
+            con = getConnection();
+            stmt = con.prepareStatement(sql);
+            return execute(stmt, params).getUpdateCount();
+        } finally {
+            closeResources(con, stmt, null);
+        }
     }
 
     /**
-     * Executes the given SQL statement with the specified parameters.
-     *
-     * @param sql statement to execute
-     * @param params parameters to set
-     * @param returnGeneratedKeys if the statement should return auto generated keys
-     * @param maxRows the maximum number of rows to return (0 for all rows)
-     * @return the <code>Statement</code> object that had been executed
-     * @throws SQLException if an error occurs
-     * @throws RepositoryException if the database driver could not be loaded
+     * Executes a general SQL statement and returns the {@link ResultSet} of the executed statement. The
+     * returned {@link ResultSet} should be closed by clients.
+     * 
+     * @param sql an SQL statement string
+     * @param params the parameters for the SQL statement
+     * @param returnGeneratedKeys whether generated keys should be returned
+     * @param maxRows the maximum number of rows in a potential {@link ResultSet} (0 means no limit)
+     * @return a {@link ResultSet}
+     * @throws SQLException on error
      */
-    private PreparedStatement executeStmtInternal(
-            String sql, Object[] params, boolean returnGeneratedKeys, int maxRows)
-            throws SQLException, RepositoryException {
-        try {            
-            PreparedStatement stmt;
-            
+    public final ResultSet exec(String sql, Object[] params, boolean returnGeneratedKeys, int maxRows)
+            throws SQLException {
+        Connection con = null;
+        PreparedStatement stmt = null;
+        ResultSet rs = null;
+        try {
+            con = getConnection();
             if (returnGeneratedKeys) {
-                stmt = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
+                stmt = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
             } else {
-                stmt = connection.prepareStatement(sql);
+                stmt = con.prepareStatement(sql);
             }
-            
             stmt.setMaxRows(maxRows);
-            return executeStmtInternal(params, stmt);
+            execute(stmt, params);
+            if (returnGeneratedKeys) {
+                rs = stmt.getGeneratedKeys();
+            } else {
+                rs = stmt.getResultSet();
+            }
+            // Don't wrap null
+            if (rs == null) {
+                return null;
+            }
+            if (inBatchMode) {
+                return new ResultSetWrapper(null, stmt, rs);
+            } else {
+                return new ResultSetWrapper(con, stmt, rs);
+            }
         } catch (SQLException e) {
-            logException("could not execute statement", e);
+            closeResources(con, stmt, rs);
             throw e;
         }
     }
 
     /**
-     * @param params the parameters for the <code>stmt</code> parameter
-     * @param stmt the statement to execute
-     * @return the executed Statement
+     * Gets a connection based on the {@code batchMode} state of this helper. The connection
+     * should be closed by a call to {@link #closeResources(Connection, Statement, ResultSet)} which
+     * also takes the {@code batchMode} state into account.
+     * 
+     * @return a {@code Connection} to use, based on the batch mode state
      * @throws SQLException on error
      */
-    private PreparedStatement executeStmtInternal(Object[] params, PreparedStatement stmt)
-            throws SQLException {
+    protected final Connection getConnection() throws SQLException {
+        if (inBatchMode) {
+            return batchConnection;
+        } else {
+            Connection con = dataSource.getConnection();
+            // JCR-1013: Setter may fail unnecessarily on a managed connection
+            if (!con.getAutoCommit()) {
+                con.setAutoCommit(true);
+            }
+            return con;
+        }
+    }
+
+    /**
+     * Closes the given resources given the {@code batchMode} state.
+     * 
+     * @param con the {@code Connection} obtained through the {@link #getConnection()} method
+     * @param stmt a {@code Statement}
+     * @param rs a {@code ResultSet}
+     */
+    protected final void closeResources(Connection con, Statement stmt, ResultSet rs) {
+        if (inBatchMode) {
+            DbUtility.close(null, stmt, rs);
+        } else {
+            DbUtility.close(con, stmt, rs);
+        }
+    }
+
+    /**
+     * @param stmt
+     * @param params
+     * @return
+     * @throws SQLException
+     */
+    private PreparedStatement execute(PreparedStatement stmt, Object[] params) throws SQLException {
         for (int i = 0; params != null && i < params.length; i++) {
             Object p = params[i];
             if (p instanceof StreamWrapper) {
                 StreamWrapper wrapper = (StreamWrapper) p;
                 stmt.setBinaryStream(i + 1, wrapper.getStream(), (int) wrapper.getSize());
-            } else if (p instanceof InputStream) {
-                InputStream stream = (InputStream) p;
-                stmt.setBinaryStream(i + 1, stream, -1);
             } else {
                 stmt.setObject(i + 1, p);
             }
         }
         stmt.execute();
-        resetStatement(stmt);
         return stmt;
     }
-
-    /**
-     * Logs an sql exception.
-     *
-     * @param message the message
-     * @param se the exception
-     */
-    private void logException(String message, SQLException se) {
-        message = message == null ? "" : message;
-        log.error(message + ", reason: " + se.getMessage() + ", state/code: " +
-                 se.getSQLState() + "/" + se.getErrorCode());
-        log.debug("   dump:", se);
-    }
-
-    public static void closeSilently(Statement statement)
-    {
-    	if (statement != null)
-    	{
-    		try
-    		{
-    			statement.close();
-    		}
-    		catch (SQLException e)
-    		{
-    			log.error("Error closing statement", e);
-    		}
-    	}
-    }
-    
-    public static void closeSilently(Connection connection)
-    {
-    	if (connection != null)
-    	{
-    		try 
-    		{
-    			connection.close();
-    		}
-    		catch (SQLException e)
-    		{
-    			log.error("Error closing connection", e);
-    		}
-    	}
-    }
-    
-    private static final Logger log = LoggerFactory.getLogger(ConnectionHelper.class);
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DbNameIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DbNameIndex.java?rev=801659&r1=801658&r2=801659&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DbNameIndex.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DbNameIndex.java Thu Aug  6 14:27:22 2009
@@ -16,14 +16,10 @@
  */
 package org.apache.jackrabbit.core.persistence.bundle.util;
 
-import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.sql.Statement;
 import java.util.HashMap;
 
-import javax.sql.DataSource;
-
 import org.apache.jackrabbit.core.util.StringIndex;
 
 /**
@@ -39,10 +35,7 @@
  */
 public class DbNameIndex implements StringIndex {
 
-    /**
-     * The class that manages statement execution and recovery from connection loss.
-     */
-    protected DataSource dataSource;
+    protected final ConnectionHelper conHelper;
 
     // name index statements
     protected String nameSelectSQL;
@@ -55,13 +48,13 @@
 
     /**
      * Creates a new index that is stored in a db.
-     * @param con the jdbc connection
+     * @param conHelper the {@link ConnectionHelper}
      * @param schemaObjectPrefix the prefix for table names
      * @throws SQLException if the statements cannot be prepared.
      */
-    public DbNameIndex(DataSource dataSource, String schemaObjectPrefix)
+    public DbNameIndex(ConnectionHelper conHlpr, String schemaObjectPrefix)
             throws SQLException {
-        this.dataSource = dataSource;
+        conHelper = conHlpr;
         init(schemaObjectPrefix);
     }
 
@@ -135,18 +128,11 @@
     protected int insertString(String string) {
         // assert index does not exist
         int result = -1;
-        Connection connection = null; 
+        ResultSet rs = null;
         try {
-        	connection = dataSource.getConnection();        	
-            Statement stmt = new ConnectionHelper(connection).executeStmt(
-                    nameInsertSQL, new Object[] { string }, true, 0);
-            ResultSet rs = stmt.getGeneratedKeys();
-            try {
-                if (rs.next()) {
-                    result = rs.getInt(1);
-                }
-            } finally {
-                rs.close();
+            rs = conHelper.exec(nameInsertSQL, new Object[] { string }, true, 0);
+            if (rs.next()) {
+                result = rs.getInt(1);
             }
         } catch (Exception e) {
             IllegalStateException ise = new IllegalStateException(
@@ -154,7 +140,7 @@
             ise.initCause(e);
             throw ise;
         } finally {
-        	ConnectionHelper.closeSilently(connection);
+        	DbUtility.close(rs);
         }
         if (result != -1) {
             return result;
@@ -170,20 +156,13 @@
      * @return the index or -1 if not found.
      */
     protected int getIndex(String string) {
-    	Connection connection = null;
+        ResultSet rs = null;
         try {
-        	connection = dataSource.getConnection();
-            Statement stmt = new ConnectionHelper(connection).executeStmt(
-                    indexSelectSQL, new Object[] { string });
-            ResultSet rs = stmt.getResultSet();
-            try {
-                if (rs.next()) {
-                    return rs.getInt(1);
-                } else {
-                    return -1;
-                }
-            } finally {
-                rs.close();
+            rs = conHelper.exec(indexSelectSQL, new Object[] { string }, false, 0);
+            if (rs.next()) {
+                return rs.getInt(1);
+            } else {
+                return -1;
             }
         } catch (Exception e) {
             IllegalStateException ise = new IllegalStateException(
@@ -191,7 +170,7 @@
             ise.initCause(e);
             throw ise;
         } finally {
-        	ConnectionHelper.closeSilently(connection);
+        	DbUtility.close(rs);
         }
     }
 
@@ -204,18 +183,11 @@
     protected String getString(int index)
             throws IllegalArgumentException, IllegalStateException {
         String result = null;
-        Connection connection = null;
+        ResultSet rs = null;
         try {
-        	connection = dataSource.getConnection();
-            Statement stmt = new ConnectionHelper(connection).executeStmt(
-                    nameSelectSQL, new Object[] { Integer.valueOf(index) });
-            ResultSet rs = stmt.getResultSet();
-            try {
-                if (rs.next()) {
-                    result = rs.getString(1);
-                }
-            } finally {
-                rs.close();
+           rs = conHelper.exec(nameSelectSQL, new Object[] { Integer.valueOf(index) }, false, 0);
+            if (rs.next()) {
+                result = rs.getString(1);
             }
         } catch (Exception e) {
             IllegalStateException ise = new IllegalStateException(
@@ -223,7 +195,7 @@
             ise.initCause(e);
             throw ise;
         } finally {
-        	ConnectionHelper.closeSilently(connection);
+        	DbUtility.close(rs);
         }
         if (result == null) {
             throw new IllegalArgumentException("Index not found: " + index);

Added: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DbUtility.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DbUtility.java?rev=801659&view=auto
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DbUtility.java (added)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DbUtility.java Thu Aug  6 14:27:22 2009
@@ -0,0 +1,96 @@
+/*
+ * 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.persistence.bundle.util;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ */
+public final class DbUtility {
+
+    private static final Logger LOG = LoggerFactory.getLogger(DbUtility.class);
+
+    /**
+     * Private constructor for utility class pattern.
+     */
+    private DbUtility() {
+    }
+
+    /**
+     * This is a utility method which closes the given resources without throwing exceptions. Any exceptions
+     * encountered are logged instead.
+     * 
+     * @param rs the {@link ResultSet} to close, may be null
+     */
+    public static void close(ResultSet rs) {
+        close(null, null, rs);
+    }
+
+    /**
+     * This is a utility method which closes the given resources without throwing exceptions. Any exceptions
+     * encountered are logged instead.
+     * 
+     * @param con the {@link Connection} to close, may be null
+     * @param stmt the {@link Statement} to close, may be null
+     * @param rs the {@link ResultSet} to close, may be null
+     */
+    public static void close(Connection con, Statement stmt, ResultSet rs) {
+        try {
+            if (con != null) {
+                con.close();
+            }
+        } catch (SQLException e) {
+            logException("failed to close Connection", e);
+        } finally {
+            try {
+                if (stmt != null) {
+                    stmt.close();
+                }
+            } catch (SQLException e) {
+                logException("failed to close Statement", e);
+            } finally {
+                try {
+                    if (rs != null) {
+                        rs.close();
+                    }
+                } catch (SQLException e) {
+                    logException("failed to close ResultSet", e);
+                }
+            }
+        }
+    }
+
+    /**
+     * Logs an SQL exception on error level, and debug level (more detail).
+     * 
+     * @param message the message
+     * @param se the exception
+     */
+    public static void logException(String message, SQLException se) {
+        LOG.error(message + ", reason: " + se.getMessage() + ", state/code: " + se.getSQLState() + "/"
+                + se.getErrorCode());
+        LOG.debug("   dump:", se);
+    }
+
+}

Propchange: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DbUtility.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DbUtility.java
------------------------------------------------------------------------------
    svn:keywords = LastChangedBy LastChangedDate LastChangedRevision HeadURL

Added: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DerbyConnectionHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DerbyConnectionHelper.java?rev=801659&view=auto
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DerbyConnectionHelper.java (added)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DerbyConnectionHelper.java Thu Aug  6 14:27:22 2009
@@ -0,0 +1,89 @@
+/*
+ * 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.persistence.bundle.util;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+import javax.sql.DataSource;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ */
+public final class DerbyConnectionHelper extends ConnectionHelper {
+
+    /** name of the embedded driver */
+    public static final String DERBY_EMBEDDED_DRIVER = "org.apache.derby.jdbc.EmbeddedDriver";
+
+    private static Logger log = LoggerFactory.getLogger(DerbyConnectionHelper.class);
+
+    /**
+     * @param dataSrc the {@link DataSource} on which this helper acts
+     */
+    public DerbyConnectionHelper(DataSource dataSrc) {
+        super(dataSrc);
+    }
+
+    /**
+     * Shuts the embedded Derby database down.
+     * 
+     * @param driver the driver
+     * @throws SQLException on failure
+     */
+    public void shutDown(String driver) throws SQLException {
+        // check for embedded driver
+        if (!DERBY_EMBEDDED_DRIVER.equals(driver)) {
+            return;
+        }
+
+        // prepare connection url for issuing shutdown command
+        String url = null;
+        Connection con = null;
+        
+        try {
+            con = dataSource.getConnection();
+            url = con.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
+            con.setAutoCommit(true);
+        }
+        finally {
+            DbUtility.close(con, null, null);
+        }
+        int pos = url.lastIndexOf(';');
+        if (pos != -1) {
+            // strip any attributes from connection url
+            url = url.substring(0, pos);
+        }
+        url += ";shutdown=true";
+
+        // 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());
+        }
+    }
+}

Propchange: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DerbyConnectionHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/DerbyConnectionHelper.java
------------------------------------------------------------------------------
    svn:keywords = LastChangedBy LastChangedDate LastChangedRevision HeadURL

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NGKDbNameIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NGKDbNameIndex.java?rev=801659&r1=801658&r2=801659&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NGKDbNameIndex.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/NGKDbNameIndex.java Thu Aug  6 14:27:22 2009
@@ -16,12 +16,9 @@
  */
 package org.apache.jackrabbit.core.persistence.bundle.util;
 
-import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
 
-import javax.sql.DataSource;
-
 /**
  * Same as {@link DbNameIndex} but does not make use of the
  * {@link Statement#RETURN_GENERATED_KEYS} feature as it might not be provided
@@ -31,13 +28,13 @@
 
     /**
      * Creates a new index that is stored in a db.
-     * @param con the ConnectionRecoveryManager
+     * @param conHelper the {@link ConnectionHelper}
      * @param schemaObjectPrefix the prefix for table names
      * @throws SQLException if the statements cannot be prepared.
      */
-    public NGKDbNameIndex(DataSource dataSource, String schemaObjectPrefix)
+    public NGKDbNameIndex(ConnectionHelper conHelper, String schemaObjectPrefix)
             throws SQLException {
-        super(dataSource, schemaObjectPrefix);
+        super(conHelper, schemaObjectPrefix);
     }
 
     /**
@@ -61,19 +58,14 @@
      */
     protected int insertString(String string) {
         // assert index does not exist
-    	Connection connection = null;
         try {
-        	connection = dataSource.getConnection();
-            new ConnectionHelper(connection).executeStmt(nameInsertSQL, new Object[] { string });
+            conHelper.exec(nameInsertSQL, new Object[] { string });
         } catch (Exception e) {
             IllegalStateException ise = new IllegalStateException(
                     "Unable to insert index for string: " + string);
             ise.initCause(e);
             throw ise;
-        } finally {
-        	ConnectionHelper.closeSilently(connection);
         }
-
         return getIndex(string);
     }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/PostgreSQLNameIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/PostgreSQLNameIndex.java?rev=801659&r1=801658&r2=801659&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/PostgreSQLNameIndex.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/PostgreSQLNameIndex.java Thu Aug  6 14:27:22 2009
@@ -16,12 +16,9 @@
  */
 package org.apache.jackrabbit.core.persistence.bundle.util;
 
-import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 
-import javax.sql.DataSource;
-
 /**
  * Same as {@link DbNameIndex} but does not make use of the
  * {@link java.sql.Statement#RETURN_GENERATED_KEYS} feature as it is not
@@ -31,9 +28,9 @@
 
     protected String generatedKeySelectSQL;
 
-    public PostgreSQLNameIndex(DataSource dataSource, String schemaObjectPrefix)
+    public PostgreSQLNameIndex(ConnectionHelper connectionHelper, String schemaObjectPrefix)
             throws SQLException {
-        super(dataSource, schemaObjectPrefix);
+        super(connectionHelper, schemaObjectPrefix);
     }
 
     /**
@@ -62,17 +59,13 @@
      */
     protected int insertString(String string) {
         // assert index does not exist
-    	Connection connection = null;
         try {
-        	connection = dataSource.getConnection();
-            new ConnectionHelper(connection).executeStmt(nameInsertSQL, new Object[]{string});
+            conHelper.exec(nameInsertSQL, new Object[]{string});
             return getGeneratedKey();
         } catch (Exception e) {        	
             IllegalStateException ise = new IllegalStateException("Unable to insert index for string: " + string);
             ise.initCause(e);
             throw ise;
-        } finally {
-        	ConnectionHelper.closeSilently(connection);
         }
     }
 
@@ -81,25 +74,20 @@
      * @return the index.
      */
     protected int getGeneratedKey() {
-    	Connection connection = null;
+        ResultSet rs = null;
         try {
-        	connection = dataSource.getConnection();        	
-            ResultSet rs = new ConnectionHelper(connection).executeQuery(generatedKeySelectSQL);
-            try {
-                if (!rs.next()) {
-                    return -1;
-                } else {
-                    return rs.getInt(1);
-                }
-            } finally {
-                rs.close();
+           rs = conHelper.exec(generatedKeySelectSQL, null, false, 0);
+            if (!rs.next()) {
+                return -1;
+            } else {
+                return rs.getInt(1);
             }
         } catch (Exception e) {
             IllegalStateException ise = new IllegalStateException("Unable to read generated index");
             ise.initCause(e);
             throw ise;
         } finally {
-        	ConnectionHelper.closeSilently(connection);
+            DbUtility.close(rs);
         }
     }
 

Added: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ResultSetWrapper.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ResultSetWrapper.java?rev=801659&view=auto
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ResultSetWrapper.java (added)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ResultSetWrapper.java Thu Aug  6 14:27:22 2009
@@ -0,0 +1,612 @@
+/*
+ * 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.persistence.bundle.util;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Map;
+
+
+/**
+ * 
+ */
+public final class ResultSetWrapper implements ResultSet {
+
+    private final Connection connection;
+
+    private final Statement statement;
+
+    private final ResultSet resultSet;
+
+    public ResultSetWrapper(Connection con, Statement stmt, ResultSet rs) {
+        connection = con;
+        statement = stmt;
+        resultSet = rs;
+    }
+
+    public boolean absolute(int row) throws SQLException {
+        return resultSet.absolute(row);
+    }
+
+    public void afterLast() throws SQLException {
+        resultSet.afterLast();
+    }
+
+    public void beforeFirst() throws SQLException {
+        resultSet.beforeFirst();
+    }
+
+    public void cancelRowUpdates() throws SQLException {
+        resultSet.cancelRowUpdates();
+    }
+
+    public void clearWarnings() throws SQLException {
+        resultSet.clearWarnings();
+    }
+
+    public void close() throws SQLException {
+        DbUtility.close(connection, statement, resultSet);
+    }
+
+    public void deleteRow() throws SQLException {
+        resultSet.deleteRow();
+    }
+
+    public int findColumn(String columnName) throws SQLException {
+        return resultSet.findColumn(columnName);
+    }
+
+    public boolean first() throws SQLException {
+        return resultSet.first();
+    }
+
+    public Array getArray(int i) throws SQLException {
+        return resultSet.getArray(i);
+    }
+
+    public Array getArray(String colName) throws SQLException {
+        return resultSet.getArray(colName);
+    }
+
+    public InputStream getAsciiStream(int columnIndex) throws SQLException {
+        return resultSet.getAsciiStream(columnIndex);
+    }
+
+    public InputStream getAsciiStream(String columnName) throws SQLException {
+        return resultSet.getAsciiStream(columnName);
+    }
+
+    public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
+        return resultSet.getBigDecimal(columnIndex);
+    }
+
+    public BigDecimal getBigDecimal(String columnName) throws SQLException {
+        return resultSet.getBigDecimal(columnName);
+    }
+
+    public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
+        return resultSet.getBigDecimal(columnIndex, scale);
+    }
+
+    public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {
+        return resultSet.getBigDecimal(columnName, scale);
+    }
+
+    public InputStream getBinaryStream(int columnIndex) throws SQLException {
+        return resultSet.getBinaryStream(columnIndex);
+    }
+
+    public InputStream getBinaryStream(String columnName) throws SQLException {
+        return resultSet.getBinaryStream(columnName);
+    }
+
+    public Blob getBlob(int i) throws SQLException {
+        return resultSet.getBlob(i);
+    }
+
+    public Blob getBlob(String colName) throws SQLException {
+        return resultSet.getBlob(colName);
+    }
+
+    public boolean getBoolean(int columnIndex) throws SQLException {
+        return resultSet.getBoolean(columnIndex);
+    }
+
+    public boolean getBoolean(String columnName) throws SQLException {
+        return resultSet.getBoolean(columnName);
+    }
+
+    public byte getByte(int columnIndex) throws SQLException {
+        return resultSet.getByte(columnIndex);
+    }
+
+    public byte getByte(String columnName) throws SQLException {
+        return resultSet.getByte(columnName);
+    }
+
+    public byte[] getBytes(int columnIndex) throws SQLException {
+        return resultSet.getBytes(columnIndex);
+    }
+
+    public byte[] getBytes(String columnName) throws SQLException {
+        return resultSet.getBytes(columnName);
+    }
+
+    public Reader getCharacterStream(int columnIndex) throws SQLException {
+        return resultSet.getCharacterStream(columnIndex);
+    }
+
+    public Reader getCharacterStream(String columnName) throws SQLException {
+        return resultSet.getCharacterStream(columnName);
+    }
+
+    public Clob getClob(int i) throws SQLException {
+        return resultSet.getClob(i);
+    }
+
+    public Clob getClob(String colName) throws SQLException {
+        return resultSet.getClob(colName);
+    }
+
+    public int getConcurrency() throws SQLException {
+        return resultSet.getConcurrency();
+    }
+
+    public String getCursorName() throws SQLException {
+        return resultSet.getCursorName();
+    }
+
+    public Date getDate(int columnIndex) throws SQLException {
+        return resultSet.getDate(columnIndex);
+    }
+
+    public Date getDate(String columnName) throws SQLException {
+        return resultSet.getDate(columnName);
+    }
+
+    public Date getDate(int columnIndex, Calendar cal) throws SQLException {
+        return resultSet.getDate(columnIndex, cal);
+    }
+
+    public Date getDate(String columnName, Calendar cal) throws SQLException {
+        return resultSet.getDate(columnName, cal);
+    }
+
+    public double getDouble(int columnIndex) throws SQLException {
+        return resultSet.getDouble(columnIndex);
+    }
+
+    public double getDouble(String columnName) throws SQLException {
+        return resultSet.getDouble(columnName);
+    }
+
+    public int getFetchDirection() throws SQLException {
+        return resultSet.getFetchDirection();
+    }
+
+    public int getFetchSize() throws SQLException {
+        return resultSet.getFetchSize();
+    }
+
+    public float getFloat(int columnIndex) throws SQLException {
+        return resultSet.getFloat(columnIndex);
+    }
+
+    public float getFloat(String columnName) throws SQLException {
+        return resultSet.getFloat(columnName);
+    }
+
+    public int getInt(int columnIndex) throws SQLException {
+        return resultSet.getInt(columnIndex);
+    }
+
+    public int getInt(String columnName) throws SQLException {
+        return resultSet.getInt(columnName);
+    }
+
+    public long getLong(int columnIndex) throws SQLException {
+        return resultSet.getLong(columnIndex);
+    }
+
+    public long getLong(String columnName) throws SQLException {
+        return resultSet.getLong(columnName);
+    }
+
+    public ResultSetMetaData getMetaData() throws SQLException {
+        return resultSet.getMetaData();
+    }
+
+    public Object getObject(int columnIndex) throws SQLException {
+        return resultSet.getObject(columnIndex);
+    }
+
+    public Object getObject(String columnName) throws SQLException {
+        return resultSet.getObject(columnName);
+    }
+
+    public Object getObject(int arg0, Map arg1) throws SQLException {
+        return resultSet.getObject(arg0, arg1);
+    }
+
+    public Object getObject(String arg0, Map arg1) throws SQLException {
+        return resultSet.getObject(arg0, arg1);
+    }
+
+    public Ref getRef(int i) throws SQLException {
+        return resultSet.getRef(i);
+    }
+
+    public Ref getRef(String colName) throws SQLException {
+        return resultSet.getRef(colName);
+    }
+
+    public int getRow() throws SQLException {
+        return resultSet.getRow();
+    }
+
+    public short getShort(int columnIndex) throws SQLException {
+        return resultSet.getShort(columnIndex);
+    }
+
+    public short getShort(String columnName) throws SQLException {
+        return resultSet.getShort(columnName);
+    }
+
+    public Statement getStatement() throws SQLException {
+        return resultSet.getStatement();
+    }
+
+    public String getString(int columnIndex) throws SQLException {
+        return resultSet.getString(columnIndex);
+    }
+
+    public String getString(String columnName) throws SQLException {
+        return resultSet.getString(columnName);
+    }
+
+    public Time getTime(int columnIndex) throws SQLException {
+        return resultSet.getTime(columnIndex);
+    }
+
+    public Time getTime(String columnName) throws SQLException {
+        return resultSet.getTime(columnName);
+    }
+
+    public Time getTime(int columnIndex, Calendar cal) throws SQLException {
+        return resultSet.getTime(columnIndex, cal);
+    }
+
+    public Time getTime(String columnName, Calendar cal) throws SQLException {
+        return resultSet.getTime(columnName, cal);
+    }
+
+    public Timestamp getTimestamp(int columnIndex) throws SQLException {
+        return resultSet.getTimestamp(columnIndex);
+    }
+
+    public Timestamp getTimestamp(String columnName) throws SQLException {
+        return resultSet.getTimestamp(columnName);
+    }
+
+    public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
+        return resultSet.getTimestamp(columnIndex, cal);
+    }
+
+    public Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException {
+        return resultSet.getTimestamp(columnName, cal);
+    }
+
+    public int getType() throws SQLException {
+        return resultSet.getType();
+    }
+
+    public URL getURL(int columnIndex) throws SQLException {
+        return resultSet.getURL(columnIndex);
+    }
+
+    public URL getURL(String columnName) throws SQLException {
+        return resultSet.getURL(columnName);
+    }
+
+    public InputStream getUnicodeStream(int columnIndex) throws SQLException {
+        return resultSet.getUnicodeStream(columnIndex);
+    }
+
+    public InputStream getUnicodeStream(String columnName) throws SQLException {
+        return resultSet.getUnicodeStream(columnName);
+    }
+
+    public SQLWarning getWarnings() throws SQLException {
+        return resultSet.getWarnings();
+    }
+
+    public void insertRow() throws SQLException {
+        resultSet.insertRow();
+    }
+
+    public boolean isAfterLast() throws SQLException {
+        return resultSet.isAfterLast();
+    }
+
+    public boolean isBeforeFirst() throws SQLException {
+        return resultSet.isBeforeFirst();
+    }
+
+    public boolean isFirst() throws SQLException {
+        return resultSet.isFirst();
+    }
+
+    public boolean isLast() throws SQLException {
+        return resultSet.isLast();
+    }
+
+    public boolean last() throws SQLException {
+        return resultSet.last();
+    }
+
+    public void moveToCurrentRow() throws SQLException {
+        resultSet.moveToCurrentRow();
+    }
+
+    public void moveToInsertRow() throws SQLException {
+        resultSet.moveToInsertRow();
+    }
+
+    public boolean next() throws SQLException {
+        return resultSet.next();
+    }
+
+    public boolean previous() throws SQLException {
+        return resultSet.previous();
+    }
+
+    public void refreshRow() throws SQLException {
+        resultSet.refreshRow();
+    }
+
+    public boolean relative(int rows) throws SQLException {
+        return resultSet.relative(rows);
+    }
+
+    public boolean rowDeleted() throws SQLException {
+        return resultSet.rowDeleted();
+    }
+
+    public boolean rowInserted() throws SQLException {
+        return resultSet.rowInserted();
+    }
+
+    public boolean rowUpdated() throws SQLException {
+        return resultSet.rowUpdated();
+    }
+
+    public void setFetchDirection(int direction) throws SQLException {
+        resultSet.setFetchDirection(direction);
+    }
+
+    public void setFetchSize(int rows) throws SQLException {
+        resultSet.setFetchSize(rows);
+    }
+
+    public void updateArray(int columnIndex, Array x) throws SQLException {
+        resultSet.updateArray(columnIndex, x);
+    }
+
+    public void updateArray(String columnName, Array x) throws SQLException {
+        resultSet.updateArray(columnName, x);
+    }
+
+    public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
+        resultSet.updateAsciiStream(columnIndex, x, length);
+    }
+
+    public void updateAsciiStream(String columnName, InputStream x, int length) throws SQLException {
+        resultSet.updateAsciiStream(columnName, x, length);
+    }
+
+    public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
+        resultSet.updateBigDecimal(columnIndex, x);
+    }
+
+    public void updateBigDecimal(String columnName, BigDecimal x) throws SQLException {
+        resultSet.updateBigDecimal(columnName, x);
+    }
+
+    public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
+        resultSet.updateBinaryStream(columnIndex, x, length);
+    }
+
+    public void updateBinaryStream(String columnName, InputStream x, int length) throws SQLException {
+        resultSet.updateBinaryStream(columnName, x, length);
+    }
+
+    public void updateBlob(int columnIndex, Blob x) throws SQLException {
+        resultSet.updateBlob(columnIndex, x);
+    }
+
+    public void updateBlob(String columnName, Blob x) throws SQLException {
+        resultSet.updateBlob(columnName, x);
+    }
+
+    public void updateBoolean(int columnIndex, boolean x) throws SQLException {
+        resultSet.updateBoolean(columnIndex, x);
+    }
+
+    public void updateBoolean(String columnName, boolean x) throws SQLException {
+        resultSet.updateBoolean(columnName, x);
+    }
+
+    public void updateByte(int columnIndex, byte x) throws SQLException {
+        resultSet.updateByte(columnIndex, x);
+    }
+
+    public void updateByte(String columnName, byte x) throws SQLException {
+        resultSet.updateByte(columnName, x);
+    }
+
+    public void updateBytes(int columnIndex, byte[] x) throws SQLException {
+        resultSet.updateBytes(columnIndex, x);
+    }
+
+    public void updateBytes(String columnName, byte[] x) throws SQLException {
+        resultSet.updateBytes(columnName, x);
+    }
+
+    public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
+        resultSet.updateCharacterStream(columnIndex, x, length);
+    }
+
+    public void updateCharacterStream(String columnName, Reader reader, int length) throws SQLException {
+        resultSet.updateCharacterStream(columnName, reader, length);
+    }
+
+    public void updateClob(int columnIndex, Clob x) throws SQLException {
+        resultSet.updateClob(columnIndex, x);
+    }
+
+    public void updateClob(String columnName, Clob x) throws SQLException {
+        resultSet.updateClob(columnName, x);
+    }
+
+    public void updateDate(int columnIndex, Date x) throws SQLException {
+        resultSet.updateDate(columnIndex, x);
+    }
+
+    public void updateDate(String columnName, Date x) throws SQLException {
+        resultSet.updateDate(columnName, x);
+    }
+
+    public void updateDouble(int columnIndex, double x) throws SQLException {
+        resultSet.updateDouble(columnIndex, x);
+    }
+
+    public void updateDouble(String columnName, double x) throws SQLException {
+        resultSet.updateDouble(columnName, x);
+    }
+
+    public void updateFloat(int columnIndex, float x) throws SQLException {
+        resultSet.updateFloat(columnIndex, x);
+    }
+
+    public void updateFloat(String columnName, float x) throws SQLException {
+        resultSet.updateFloat(columnName, x);
+    }
+
+    public void updateInt(int columnIndex, int x) throws SQLException {
+        resultSet.updateInt(columnIndex, x);
+    }
+
+    public void updateInt(String columnName, int x) throws SQLException {
+        resultSet.updateInt(columnName, x);
+    }
+
+    public void updateLong(int columnIndex, long x) throws SQLException {
+        resultSet.updateLong(columnIndex, x);
+    }
+
+    public void updateLong(String columnName, long x) throws SQLException {
+        resultSet.updateLong(columnName, x);
+    }
+
+    public void updateNull(int columnIndex) throws SQLException {
+        resultSet.updateNull(columnIndex);
+    }
+
+    public void updateNull(String columnName) throws SQLException {
+        resultSet.updateNull(columnName);
+    }
+
+    public void updateObject(int columnIndex, Object x) throws SQLException {
+        resultSet.updateObject(columnIndex, x);
+    }
+
+    public void updateObject(String columnName, Object x) throws SQLException {
+        resultSet.updateObject(columnName, x);
+    }
+
+    public void updateObject(int columnIndex, Object x, int scale) throws SQLException {
+        resultSet.updateObject(columnIndex, x, scale);
+    }
+
+    public void updateObject(String columnName, Object x, int scale) throws SQLException {
+        resultSet.updateObject(columnName, x, scale);
+    }
+
+    public void updateRef(int columnIndex, Ref x) throws SQLException {
+        resultSet.updateRef(columnIndex, x);
+    }
+
+    public void updateRef(String columnName, Ref x) throws SQLException {
+        resultSet.updateRef(columnName, x);
+    }
+
+    public void updateRow() throws SQLException {
+        resultSet.updateRow();
+    }
+
+    public void updateShort(int columnIndex, short x) throws SQLException {
+        resultSet.updateShort(columnIndex, x);
+    }
+
+    public void updateShort(String columnName, short x) throws SQLException {
+        resultSet.updateShort(columnName, x);
+    }
+
+    public void updateString(int columnIndex, String x) throws SQLException {
+        resultSet.updateString(columnIndex, x);
+    }
+
+    public void updateString(String columnName, String x) throws SQLException {
+        resultSet.updateString(columnName, x);
+    }
+
+    public void updateTime(int columnIndex, Time x) throws SQLException {
+        resultSet.updateTime(columnIndex, x);
+    }
+
+    public void updateTime(String columnName, Time x) throws SQLException {
+        resultSet.updateTime(columnName, x);
+    }
+
+    public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
+        resultSet.updateTimestamp(columnIndex, x);
+    }
+
+    public void updateTimestamp(String columnName, Timestamp x) throws SQLException {
+        resultSet.updateTimestamp(columnName, x);
+    }
+
+    public boolean wasNull() throws SQLException {
+        return resultSet.wasNull();
+    }
+}

Propchange: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ResultSetWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/ResultSetWrapper.java
------------------------------------------------------------------------------
    svn:keywords = LastChangedBy LastChangedDate LastChangedRevision HeadURL

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/db/DerbyFileSystemTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/db/DerbyFileSystemTest.java?rev=801659&r1=801658&r2=801659&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/db/DerbyFileSystemTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/fs/db/DerbyFileSystemTest.java Thu Aug  6 14:27:22 2009
@@ -17,8 +17,8 @@
 package org.apache.jackrabbit.core.fs.db;
 
 import java.io.File;
-import java.io.IOException;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.core.fs.AbstractFileSystemTest;
 import org.apache.jackrabbit.core.fs.FileSystem;
 
@@ -40,15 +40,6 @@
 
     protected void tearDown() throws Exception {
         super.tearDown();
-        delete(file);
+        FileUtils.deleteDirectory(file);
     }
-
-    private void delete(File file) throws IOException {
-        File[] files = file.listFiles();
-        for (int i = 0; files != null && i < files.length; i++) {
-            delete(files[i]);
-        }
-        file.delete();
-    }
-
 }