You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/06/20 14:57:31 UTC

commons-dbcp git commit: Sort members in AB order to make it easier to find stuff.

Repository: commons-dbcp
Updated Branches:
  refs/heads/master 8e4a56526 -> bc4cd88aa


Sort members in AB order to make it easier to find stuff.

Project: http://git-wip-us.apache.org/repos/asf/commons-dbcp/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbcp/commit/bc4cd88a
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbcp/tree/bc4cd88a
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbcp/diff/bc4cd88a

Branch: refs/heads/master
Commit: bc4cd88aa7d8343dbb031c65d141f4b021a95d0a
Parents: 8e4a565
Author: Gary Gregory <ga...@gmail.com>
Authored: Wed Jun 20 08:57:28 2018 -0600
Committer: Gary Gregory <ga...@gmail.com>
Committed: Wed Jun 20 08:57:28 2018 -0600

----------------------------------------------------------------------
 .../java/org/apache/commons/dbcp2/PStmtKey.java | 622 +++++++++----------
 1 file changed, 311 insertions(+), 311 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/bc4cd88a/src/main/java/org/apache/commons/dbcp2/PStmtKey.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbcp2/PStmtKey.java b/src/main/java/org/apache/commons/dbcp2/PStmtKey.java
index 81ff896..e118a2c 100644
--- a/src/main/java/org/apache/commons/dbcp2/PStmtKey.java
+++ b/src/main/java/org/apache/commons/dbcp2/PStmtKey.java
@@ -31,6 +31,105 @@ import org.apache.commons.dbcp2.PoolingConnection.StatementType;
 public class PStmtKey {
 
     /**
+     * Builder for prepareCall(String sql).
+     */
+    private class PreparedCallSQL implements StatementBuilder {
+        @Override
+        public Statement createStatement(final Connection connection) throws SQLException {
+            return connection.prepareCall(sql);
+        }
+    }
+
+    /**
+     * Builder for prepareCall(String sql, int resultSetType, int resultSetConcurrency).
+     */
+    private class PreparedCallWithResultSetConcurrency implements StatementBuilder {
+        @Override
+        public Statement createStatement(final Connection connection) throws SQLException {
+            return connection.prepareCall(sql, resultSetType.intValue(), resultSetConcurrency.intValue());
+        }
+    }
+
+    /**
+     * Builder for prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability).
+     */
+    private class PreparedCallWithResultSetHoldability implements StatementBuilder {
+        @Override
+        public Statement createStatement(final Connection connection) throws SQLException {
+            return connection.prepareCall(sql, resultSetType.intValue(), resultSetConcurrency.intValue(),
+                    resultSetHoldability.intValue());
+        }
+    }
+
+    /**
+     * Builder for prepareStatement(String sql).
+     */
+    private class PreparedStatementSQL implements StatementBuilder {
+        @Override
+        public Statement createStatement(final Connection connection) throws SQLException {
+            return connection.prepareStatement(sql);
+        }
+    }
+
+    /**
+     * Builder for prepareStatement(String sql, int autoGeneratedKeys).
+     */
+    private class PreparedStatementWithAutoGeneratedKeys implements StatementBuilder {
+        @Override
+        public Statement createStatement(final Connection connection) throws SQLException {
+            return connection.prepareStatement(sql, autoGeneratedKeys.intValue());
+        }
+    }
+
+    /**
+     * Builder for prepareStatement(String sql, int[] columnIndexes).
+     */
+    private class PreparedStatementWithColumnIndexes implements StatementBuilder {
+        @Override
+        public Statement createStatement(final Connection connection) throws SQLException {
+            return connection.prepareStatement(sql, columnIndexes);
+        }
+    }
+
+    /**
+     * Builder for prepareStatement(String sql, String[] columnNames).
+     */
+    private class PreparedStatementWithColumnNames implements StatementBuilder {
+        @Override
+        public Statement createStatement(final Connection connection) throws SQLException {
+            return connection.prepareStatement(sql, columnNames);
+        }
+    }
+
+    /**
+     * Builder for prepareStatement(String sql, int resultSetType, int resultSetConcurrency).
+     */
+    private class PreparedStatementWithResultSetConcurrency implements StatementBuilder {
+        @Override
+        public Statement createStatement(final Connection connection) throws SQLException {
+            return connection.prepareStatement(sql, resultSetType.intValue(), resultSetConcurrency.intValue());
+        }
+    }
+
+    /**
+     * Builder for prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability).
+     */
+    private class PreparedStatementWithResultSetHoldability implements StatementBuilder {
+        @Override
+        public Statement createStatement(final Connection connection) throws SQLException {
+            return connection.prepareStatement(sql, resultSetType.intValue(), resultSetConcurrency.intValue(),
+                    resultSetHoldability.intValue());
+        }
+    }
+
+    /**
+     * Interface for Prepared or Callable Statement.
+     */
+    private interface StatementBuilder {
+        public Statement createStatement(Connection connection) throws SQLException;
+    }
+
+    /**
      * SQL defining Prepared or Callable Statement
      */
     private final String sql;
@@ -95,11 +194,15 @@ public class PStmtKey {
      *
      * @param sql
      *            The SQL statement.
-     * @param catalog
-     *            The catalog.
+     * @param resultSetType
+     *            A result set type; one of <code>ResultSet.TYPE_FORWARD_ONLY</code>,
+     *            <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>.
+     * @param resultSetConcurrency
+     *            A concurrency type; one of <code>ResultSet.CONCUR_READ_ONLY</code> or
+     *            <code>ResultSet.CONCUR_UPDATABLE</code>.
      */
-    public PStmtKey(final String sql, final String catalog) {
-        this(sql, catalog, StatementType.PREPARED_STATEMENT);
+    public PStmtKey(final String sql, final int resultSetType, final int resultSetConcurrency) {
+        this(sql, null, resultSetType, resultSetConcurrency, StatementType.PREPARED_STATEMENT);
     }
 
     /**
@@ -109,25 +212,9 @@ public class PStmtKey {
      *            The SQL statement.
      * @param catalog
      *            The catalog.
-     * @param statementType
-     *            The SQL statement type, prepared or callable.
      */
-    public PStmtKey(final String sql, final String catalog, final StatementType statementType) {
-        this.sql = sql;
-        this.catalog = catalog;
-        this.statementType = statementType;
-        this.autoGeneratedKeys = null;
-        this.columnIndexes = null;
-        this.columnNames = null;
-        this.resultSetType = null;
-        this.resultSetConcurrency = null;
-        this.resultSetHoldability = null;
-        // create builder
-        if (statementType == StatementType.PREPARED_STATEMENT) {
-            this.builder = new PreparedStatementSQL();
-        } else if (statementType == StatementType.CALLABLE_STATEMENT) {
-            this.builder = new PreparedCallSQL();
-        }
+    public PStmtKey(final String sql, final String catalog) {
+        this(sql, catalog, StatementType.PREPARED_STATEMENT);
     }
 
     /**
@@ -152,54 +239,15 @@ public class PStmtKey {
      *            The SQL statement.
      * @param catalog
      *            The catalog.
-     * @param statementType
-     *            The SQL statement type, prepared or callable.
-     * @param autoGeneratedKeys
-     *            A flag indicating whether auto-generated keys should be returned; one of
-     *            <code>Statement.RETURN_GENERATED_KEYS</code> or <code>Statement.NO_GENERATED_KEYS</code>.
-     */
-    public PStmtKey(final String sql, final String catalog, final StatementType statementType,
-            final Integer autoGeneratedKeys) {
-        this.sql = sql;
-        this.catalog = catalog;
-        this.statementType = statementType;
-        this.autoGeneratedKeys = autoGeneratedKeys;
-        this.columnIndexes = null;
-        this.columnNames = null;
-        this.resultSetType = null;
-        this.resultSetConcurrency = null;
-        this.resultSetHoldability = null;
-        // create builder
-        if (statementType == StatementType.PREPARED_STATEMENT) {
-            this.builder = new PreparedStatementWithAutoGeneratedKeys();
-        } else if (statementType == StatementType.CALLABLE_STATEMENT) {
-            this.builder = new PreparedCallSQL();
-        }
-    }
-
-    /**
-     * Constructs a key to uniquely identify a prepared statement.
-     *
-     * @param sql
-     *            The SQL statement.
-     * @param catalog
-     *            The catalog.
-     * @param columnIndexes
-     *            An array of column indexes indicating the columns that should be returned from the inserted row or
-     *            rows.
+     * @param resultSetType
+     *            A result set type; one of <code>ResultSet.TYPE_FORWARD_ONLY</code>,
+     *            <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>.
+     * @param resultSetConcurrency
+     *            A concurrency type; one of <code>ResultSet.CONCUR_READ_ONLY</code> or
+     *            <code>ResultSet.CONCUR_UPDATABLE</code>.
      */
-    public PStmtKey(final String sql, final String catalog, final int[] columnIndexes) {
-        this.sql = sql;
-        this.catalog = catalog;
-        this.statementType = StatementType.PREPARED_STATEMENT;
-        this.autoGeneratedKeys = null;
-        this.columnIndexes = columnIndexes == null ? null : Arrays.copyOf(columnIndexes, columnIndexes.length);
-        this.columnNames = null;
-        this.resultSetType = null;
-        this.resultSetConcurrency = null;
-        this.resultSetHoldability = null;
-        // create builder
-        this.builder = new PreparedStatementWithColumnIndexes();
+    public PStmtKey(final String sql, final String catalog, final int resultSetType, final int resultSetConcurrency) {
+        this(sql, catalog, resultSetType, resultSetConcurrency, StatementType.PREPARED_STATEMENT);
     }
 
     /**
@@ -209,37 +257,19 @@ public class PStmtKey {
      *            The SQL statement.
      * @param catalog
      *            The catalog.
-     * @param columnNames
-     *            An array of column names indicating the columns that should be returned from the inserted row or rows.
-     */
-    public PStmtKey(final String sql, final String catalog, final String[] columnNames) {
-        this.sql = sql;
-        this.catalog = catalog;
-        this.statementType = StatementType.PREPARED_STATEMENT;
-        this.autoGeneratedKeys = null;
-        this.columnIndexes = null;
-        this.columnNames = columnNames == null ? null : Arrays.copyOf(columnNames, columnNames.length);
-        this.resultSetType = null;
-        this.resultSetConcurrency = null;
-        this.resultSetHoldability = null;
-        // create builder
-        builder = new PreparedStatementWithColumnNames();
-    }
-
-    /**
-     * Constructs a key to uniquely identify a prepared statement.
-     *
-     * @param sql
-     *            The SQL statement.
      * @param resultSetType
-     *            A result set type; one of <code>ResultSet.TYPE_FORWARD_ONLY</code>,
+     *            a result set type; one of <code>ResultSet.TYPE_FORWARD_ONLY</code>,
      *            <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>.
      * @param resultSetConcurrency
      *            A concurrency type; one of <code>ResultSet.CONCUR_READ_ONLY</code> or
-     *            <code>ResultSet.CONCUR_UPDATABLE</code>.
+     *            <code>ResultSet.CONCUR_UPDATABLE</code>
+     * @param resultSetHoldability
+     *            One of the following <code>ResultSet</code> constants: <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code>
+     *            or <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>.
      */
-    public PStmtKey(final String sql, final int resultSetType, final int resultSetConcurrency) {
-        this(sql, null, resultSetType, resultSetConcurrency, StatementType.PREPARED_STATEMENT);
+    public PStmtKey(final String sql, final String catalog, final int resultSetType, final int resultSetConcurrency,
+            final int resultSetHoldability) {
+        this(sql, catalog, resultSetType, resultSetConcurrency, resultSetHoldability, StatementType.PREPARED_STATEMENT);
     }
 
     /**
@@ -250,14 +280,34 @@ public class PStmtKey {
      * @param catalog
      *            The catalog.
      * @param resultSetType
-     *            A result set type; one of <code>ResultSet.TYPE_FORWARD_ONLY</code>,
-     *            <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>.
+     *            a result set type; one of <code>ResultSet.TYPE_FORWARD_ONLY</code>,
+     *            <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
      * @param resultSetConcurrency
      *            A concurrency type; one of <code>ResultSet.CONCUR_READ_ONLY</code> or
      *            <code>ResultSet.CONCUR_UPDATABLE</code>.
+     * @param resultSetHoldability
+     *            One of the following <code>ResultSet</code> constants: <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code>
+     *            or <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>.
+     * @param statementType
+     *            The SQL statement type, prepared or callable.
      */
-    public PStmtKey(final String sql, final String catalog, final int resultSetType, final int resultSetConcurrency) {
-        this(sql, catalog, resultSetType, resultSetConcurrency, StatementType.PREPARED_STATEMENT);
+    public PStmtKey(final String sql, final String catalog, final int resultSetType, final int resultSetConcurrency,
+            final int resultSetHoldability, final StatementType statementType) {
+        this.sql = sql;
+        this.catalog = catalog;
+        this.resultSetType = Integer.valueOf(resultSetType);
+        this.resultSetConcurrency = Integer.valueOf(resultSetConcurrency);
+        this.resultSetHoldability = Integer.valueOf(resultSetHoldability);
+        this.statementType = statementType;
+        this.autoGeneratedKeys = null;
+        this.columnIndexes = null;
+        this.columnNames = null;
+        // create builder
+        if (statementType == StatementType.PREPARED_STATEMENT) {
+            this.builder = new PreparedStatementWithResultSetHoldability();
+        } else if (statementType == StatementType.CALLABLE_STATEMENT) {
+            this.builder = new PreparedCallWithResultSetHoldability();
+        }
     }
 
     /**
@@ -302,19 +352,22 @@ public class PStmtKey {
      *            The SQL statement.
      * @param catalog
      *            The catalog.
-     * @param resultSetType
-     *            a result set type; one of <code>ResultSet.TYPE_FORWARD_ONLY</code>,
-     *            <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>.
-     * @param resultSetConcurrency
-     *            A concurrency type; one of <code>ResultSet.CONCUR_READ_ONLY</code> or
-     *            <code>ResultSet.CONCUR_UPDATABLE</code>
-     * @param resultSetHoldability
-     *            One of the following <code>ResultSet</code> constants: <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code>
-     *            or <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>.
+     * @param columnIndexes
+     *            An array of column indexes indicating the columns that should be returned from the inserted row or
+     *            rows.
      */
-    public PStmtKey(final String sql, final String catalog, final int resultSetType, final int resultSetConcurrency,
-            final int resultSetHoldability) {
-        this(sql, catalog, resultSetType, resultSetConcurrency, resultSetHoldability, StatementType.PREPARED_STATEMENT);
+    public PStmtKey(final String sql, final String catalog, final int[] columnIndexes) {
+        this.sql = sql;
+        this.catalog = catalog;
+        this.statementType = StatementType.PREPARED_STATEMENT;
+        this.autoGeneratedKeys = null;
+        this.columnIndexes = columnIndexes == null ? null : Arrays.copyOf(columnIndexes, columnIndexes.length);
+        this.columnNames = null;
+        this.resultSetType = null;
+        this.resultSetConcurrency = null;
+        this.resultSetHoldability = null;
+        // create builder
+        this.builder = new PreparedStatementWithColumnIndexes();
     }
 
     /**
@@ -324,120 +377,97 @@ public class PStmtKey {
      *            The SQL statement.
      * @param catalog
      *            The catalog.
-     * @param resultSetType
-     *            a result set type; one of <code>ResultSet.TYPE_FORWARD_ONLY</code>,
-     *            <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
-     * @param resultSetConcurrency
-     *            A concurrency type; one of <code>ResultSet.CONCUR_READ_ONLY</code> or
-     *            <code>ResultSet.CONCUR_UPDATABLE</code>.
-     * @param resultSetHoldability
-     *            One of the following <code>ResultSet</code> constants: <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code>
-     *            or <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>.
      * @param statementType
      *            The SQL statement type, prepared or callable.
      */
-    public PStmtKey(final String sql, final String catalog, final int resultSetType, final int resultSetConcurrency,
-            final int resultSetHoldability, final StatementType statementType) {
+    public PStmtKey(final String sql, final String catalog, final StatementType statementType) {
         this.sql = sql;
         this.catalog = catalog;
-        this.resultSetType = Integer.valueOf(resultSetType);
-        this.resultSetConcurrency = Integer.valueOf(resultSetConcurrency);
-        this.resultSetHoldability = Integer.valueOf(resultSetHoldability);
         this.statementType = statementType;
         this.autoGeneratedKeys = null;
         this.columnIndexes = null;
         this.columnNames = null;
+        this.resultSetType = null;
+        this.resultSetConcurrency = null;
+        this.resultSetHoldability = null;
         // create builder
         if (statementType == StatementType.PREPARED_STATEMENT) {
-            this.builder = new PreparedStatementWithResultSetHoldability();
+            this.builder = new PreparedStatementSQL();
         } else if (statementType == StatementType.CALLABLE_STATEMENT) {
-            this.builder = new PreparedCallWithResultSetHoldability();
+            this.builder = new PreparedCallSQL();
         }
     }
 
     /**
-     * Gets the SQL statement.
-     *
-     * @return the SQL statement.
-     */
-    public String getSql() {
-        return sql;
-    }
-
-    /**
-     * Gets the result set type, one of <code>ResultSet.TYPE_FORWARD_ONLY</code>,
-     * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>.
-     *
-     * @return the result set type.
-     */
-    public Integer getResultSetType() {
-        return resultSetType;
-    }
-
-    /**
-     * Gets the result set concurrency type; one of <code>ResultSet.CONCUR_READ_ONLY</code> or
-     * <code>ResultSet.CONCUR_UPDATABLE</code>.
-     *
-     * @return The result set concurrency type.
-     */
-    public Integer getResultSetConcurrency() {
-        return resultSetConcurrency;
-    }
-
-    /**
-     * Gets the result set holdability, one of the following <code>ResultSet</code> constants:
-     * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>.
-     *
-     * @return The result set holdability.
-     */
-    public Integer getResultSetHoldability() {
-        return resultSetHoldability;
-    }
-
-    /**
-     * Gets a flag indicating whether auto-generated keys should be returned; one of
-     * <code>Statement.RETURN_GENERATED_KEYS</code> or <code>Statement.NO_GENERATED_KEYS</code>.
-     *
-     * @return a flag indicating whether auto-generated keys should be returned.
-     */
-    public Integer getAutoGeneratedKeys() {
-        return autoGeneratedKeys;
-    }
-
-    /**
-     * Gets an array of column indexes indicating the columns that should be returned from the inserted row or rows.
-     *
-     * @return An array of column indexes.
-     */
-    public int[] getColumnIndexes() {
-        return columnIndexes;
-    }
-
-    /**
-     * Gets an array of column names indicating the columns that should be returned from the inserted row or rows.
+     * Constructs a key to uniquely identify a prepared statement.
      *
-     * @return An array of column names.
+     * @param sql
+     *            The SQL statement.
+     * @param catalog
+     *            The catalog.
+     * @param statementType
+     *            The SQL statement type, prepared or callable.
+     * @param autoGeneratedKeys
+     *            A flag indicating whether auto-generated keys should be returned; one of
+     *            <code>Statement.RETURN_GENERATED_KEYS</code> or <code>Statement.NO_GENERATED_KEYS</code>.
      */
-    public String[] getColumnNames() {
-        return columnNames;
+    public PStmtKey(final String sql, final String catalog, final StatementType statementType,
+            final Integer autoGeneratedKeys) {
+        this.sql = sql;
+        this.catalog = catalog;
+        this.statementType = statementType;
+        this.autoGeneratedKeys = autoGeneratedKeys;
+        this.columnIndexes = null;
+        this.columnNames = null;
+        this.resultSetType = null;
+        this.resultSetConcurrency = null;
+        this.resultSetHoldability = null;
+        // create builder
+        if (statementType == StatementType.PREPARED_STATEMENT) {
+            this.builder = new PreparedStatementWithAutoGeneratedKeys();
+        } else if (statementType == StatementType.CALLABLE_STATEMENT) {
+            this.builder = new PreparedCallSQL();
+        }
     }
 
     /**
-     * The catalog.
+     * Constructs a key to uniquely identify a prepared statement.
      *
-     * @return The catalog.
+     * @param sql
+     *            The SQL statement.
+     * @param catalog
+     *            The catalog.
+     * @param columnNames
+     *            An array of column names indicating the columns that should be returned from the inserted row or rows.
      */
-    public String getCatalog() {
-        return catalog;
+    public PStmtKey(final String sql, final String catalog, final String[] columnNames) {
+        this.sql = sql;
+        this.catalog = catalog;
+        this.statementType = StatementType.PREPARED_STATEMENT;
+        this.autoGeneratedKeys = null;
+        this.columnIndexes = null;
+        this.columnNames = columnNames == null ? null : Arrays.copyOf(columnNames, columnNames.length);
+        this.resultSetType = null;
+        this.resultSetConcurrency = null;
+        this.resultSetHoldability = null;
+        // create builder
+        builder = new PreparedStatementWithColumnNames();
     }
 
     /**
-     * The SQL statement type.
+     * Creates a new Statement from the given Connection.
      *
-     * @return The SQL statement type.
+     * @param connection
+     *            The Connection to use to create the statement.
+     * @return The statement.
+     * @throws SQLException
+     *             Thrown when there is a problem creating the statement.
      */
-    public StatementType getStmtType() {
-        return statementType;
+    public Statement createStatement(final Connection connection) throws SQLException {
+        if (builder == null) {
+            throw new IllegalStateException("Prepared statement key is invalid.");
+        }
+        return builder.createStatement(connection);
     }
 
     @Override
@@ -506,158 +536,128 @@ public class PStmtKey {
         return true;
     }
 
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + (catalog == null ? 0 : catalog.hashCode());
-        result = prime * result + (resultSetConcurrency == null ? 0 : resultSetConcurrency.hashCode());
-        result = prime * result + (resultSetType == null ? 0 : resultSetType.hashCode());
-        result = prime * result + (resultSetHoldability == null ? 0 : resultSetHoldability.hashCode());
-        result = prime * result + (sql == null ? 0 : sql.hashCode());
-        result = prime * result + (autoGeneratedKeys == null ? 0 : autoGeneratedKeys.hashCode());
-        result = prime * result + Arrays.hashCode(columnIndexes);
-        result = prime * result + Arrays.hashCode(columnNames);
-        result = prime * result + statementType.hashCode();
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        final StringBuffer buf = new StringBuffer();
-        buf.append("PStmtKey: sql=");
-        buf.append(sql);
-        buf.append(", catalog=");
-        buf.append(catalog);
-        buf.append(", resultSetType=");
-        buf.append(resultSetType);
-        buf.append(", resultSetConcurrency=");
-        buf.append(resultSetConcurrency);
-        buf.append(", resultSetHoldability=");
-        buf.append(resultSetHoldability);
-        buf.append(", autoGeneratedKeys=");
-        buf.append(autoGeneratedKeys);
-        buf.append(", columnIndexes=");
-        buf.append(Arrays.toString(columnIndexes));
-        buf.append(", columnNames=");
-        buf.append(Arrays.toString(columnNames));
-        buf.append(", statementType=");
-        buf.append(statementType);
-        return buf.toString();
-    }
-
     /**
-     * Creates a new Statement from the given Connection.
+     * Gets a flag indicating whether auto-generated keys should be returned; one of
+     * <code>Statement.RETURN_GENERATED_KEYS</code> or <code>Statement.NO_GENERATED_KEYS</code>.
      *
-     * @param connection
-     *            The Connection to use to create the statement.
-     * @return The statement.
-     * @throws SQLException
-     *             Thrown when there is a problem creating the statement.
+     * @return a flag indicating whether auto-generated keys should be returned.
      */
-    public Statement createStatement(final Connection connection) throws SQLException {
-        if (builder == null) {
-            throw new IllegalStateException("Prepared statement key is invalid.");
-        }
-        return builder.createStatement(connection);
+    public Integer getAutoGeneratedKeys() {
+        return autoGeneratedKeys;
     }
 
     /**
-     * Interface for Prepared or Callable Statement.
+     * The catalog.
+     *
+     * @return The catalog.
      */
-    private interface StatementBuilder {
-        public Statement createStatement(Connection connection) throws SQLException;
+    public String getCatalog() {
+        return catalog;
     }
 
     /**
-     * Builder for prepareStatement(String sql).
+     * Gets an array of column indexes indicating the columns that should be returned from the inserted row or rows.
+     *
+     * @return An array of column indexes.
      */
-    private class PreparedStatementSQL implements StatementBuilder {
-        @Override
-        public Statement createStatement(final Connection connection) throws SQLException {
-            return connection.prepareStatement(sql);
-        }
+    public int[] getColumnIndexes() {
+        return columnIndexes;
     }
 
     /**
-     * Builder for prepareStatement(String sql, int autoGeneratedKeys).
+     * Gets an array of column names indicating the columns that should be returned from the inserted row or rows.
+     *
+     * @return An array of column names.
      */
-    private class PreparedStatementWithAutoGeneratedKeys implements StatementBuilder {
-        @Override
-        public Statement createStatement(final Connection connection) throws SQLException {
-            return connection.prepareStatement(sql, autoGeneratedKeys.intValue());
-        }
+    public String[] getColumnNames() {
+        return columnNames;
     }
 
     /**
-     * Builder for prepareStatement(String sql, int[] columnIndexes).
+     * Gets the result set concurrency type; one of <code>ResultSet.CONCUR_READ_ONLY</code> or
+     * <code>ResultSet.CONCUR_UPDATABLE</code>.
+     *
+     * @return The result set concurrency type.
      */
-    private class PreparedStatementWithColumnIndexes implements StatementBuilder {
-        @Override
-        public Statement createStatement(final Connection connection) throws SQLException {
-            return connection.prepareStatement(sql, columnIndexes);
-        }
+    public Integer getResultSetConcurrency() {
+        return resultSetConcurrency;
     }
 
     /**
-     * Builder for prepareStatement(String sql, int resultSetType, int resultSetConcurrency).
+     * Gets the result set holdability, one of the following <code>ResultSet</code> constants:
+     * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>.
+     *
+     * @return The result set holdability.
      */
-    private class PreparedStatementWithResultSetConcurrency implements StatementBuilder {
-        @Override
-        public Statement createStatement(final Connection connection) throws SQLException {
-            return connection.prepareStatement(sql, resultSetType.intValue(), resultSetConcurrency.intValue());
-        }
+    public Integer getResultSetHoldability() {
+        return resultSetHoldability;
     }
 
     /**
-     * Builder for prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability).
+     * Gets the result set type, one of <code>ResultSet.TYPE_FORWARD_ONLY</code>,
+     * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>.
+     *
+     * @return the result set type.
      */
-    private class PreparedStatementWithResultSetHoldability implements StatementBuilder {
-        @Override
-        public Statement createStatement(final Connection connection) throws SQLException {
-            return connection.prepareStatement(sql, resultSetType.intValue(), resultSetConcurrency.intValue(),
-                    resultSetHoldability.intValue());
-        }
+    public Integer getResultSetType() {
+        return resultSetType;
     }
 
     /**
-     * Builder for prepareStatement(String sql, String[] columnNames).
+     * Gets the SQL statement.
+     *
+     * @return the SQL statement.
      */
-    private class PreparedStatementWithColumnNames implements StatementBuilder {
-        @Override
-        public Statement createStatement(final Connection connection) throws SQLException {
-            return connection.prepareStatement(sql, columnNames);
-        }
+    public String getSql() {
+        return sql;
     }
 
     /**
-     * Builder for prepareCall(String sql).
+     * The SQL statement type.
+     *
+     * @return The SQL statement type.
      */
-    private class PreparedCallSQL implements StatementBuilder {
-        @Override
-        public Statement createStatement(final Connection connection) throws SQLException {
-            return connection.prepareCall(sql);
-        }
+    public StatementType getStmtType() {
+        return statementType;
     }
 
-    /**
-     * Builder for prepareCall(String sql, int resultSetType, int resultSetConcurrency).
-     */
-    private class PreparedCallWithResultSetConcurrency implements StatementBuilder {
-        @Override
-        public Statement createStatement(final Connection connection) throws SQLException {
-            return connection.prepareCall(sql, resultSetType.intValue(), resultSetConcurrency.intValue());
-        }
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (catalog == null ? 0 : catalog.hashCode());
+        result = prime * result + (resultSetConcurrency == null ? 0 : resultSetConcurrency.hashCode());
+        result = prime * result + (resultSetType == null ? 0 : resultSetType.hashCode());
+        result = prime * result + (resultSetHoldability == null ? 0 : resultSetHoldability.hashCode());
+        result = prime * result + (sql == null ? 0 : sql.hashCode());
+        result = prime * result + (autoGeneratedKeys == null ? 0 : autoGeneratedKeys.hashCode());
+        result = prime * result + Arrays.hashCode(columnIndexes);
+        result = prime * result + Arrays.hashCode(columnNames);
+        result = prime * result + statementType.hashCode();
+        return result;
     }
 
-    /**
-     * Builder for prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability).
-     */
-    private class PreparedCallWithResultSetHoldability implements StatementBuilder {
-        @Override
-        public Statement createStatement(final Connection connection) throws SQLException {
-            return connection.prepareCall(sql, resultSetType.intValue(), resultSetConcurrency.intValue(),
-                    resultSetHoldability.intValue());
-        }
+    @Override
+    public String toString() {
+        final StringBuffer buf = new StringBuffer();
+        buf.append("PStmtKey: sql=");
+        buf.append(sql);
+        buf.append(", catalog=");
+        buf.append(catalog);
+        buf.append(", resultSetType=");
+        buf.append(resultSetType);
+        buf.append(", resultSetConcurrency=");
+        buf.append(resultSetConcurrency);
+        buf.append(", resultSetHoldability=");
+        buf.append(resultSetHoldability);
+        buf.append(", autoGeneratedKeys=");
+        buf.append(autoGeneratedKeys);
+        buf.append(", columnIndexes=");
+        buf.append(Arrays.toString(columnIndexes));
+        buf.append(", columnNames=");
+        buf.append(Arrays.toString(columnNames));
+        buf.append(", statementType=");
+        buf.append(statementType);
+        return buf.toString();
     }
 }