/*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * (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.mozilla.org/MPL/>.
 * 
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
 * language governing rights and limitations under the License.
 * 
 * The Original Code is the Venice Web Communities System.
 * 
 * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
 * for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
 * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.
 * 
 * Contributor(s): 
 */
package com.silverwrist.venice.db;

import java.sql.*;

class WrappedConnection implements Connection
{
  /*--------------------------------------------------------------------------------
   * Attributes
   *--------------------------------------------------------------------------------
   */

  private DataPool datapool;
  private Connection conn;

  /*--------------------------------------------------------------------------------
   * Constructor
   *--------------------------------------------------------------------------------
   */

  WrappedConnection(DataPool datapool, Connection conn)
  {
    this.datapool = datapool;
    this.conn = conn;

  } // end constructor

  /*--------------------------------------------------------------------------------
   * Overrides from class Object
   *--------------------------------------------------------------------------------
   */

  protected void finalize() throws Throwable
  {
    if (conn!=null)
      this.close();
    super.finalize();

  } // end finalize

  /*--------------------------------------------------------------------------------
   * Implementations from interface Connection
   *--------------------------------------------------------------------------------
   */

  /**
   * Creates a <code>Statement</code> object for sending
   * SQL statements to the database.
   *
   * @return a new Statement object 
   * @exception SQLException if a database access error occurs
   */
  public Statement createStatement() throws SQLException
  {
    return conn.createStatement();

  } // end createStatement

  /**
   * Creates a <code>PreparedStatement</code> object for sending
   * parameterized SQL statements to the database.
   *
   * @param sql a SQL statement that may contain one or more '?' IN parameter placeholders
   * @return a new PreparedStatement object containing the pre-compiled statement 
   * @exception SQLException if a database access error occurs
   */
  public PreparedStatement prepareStatement(String sql) throws SQLException
  {
    return conn.prepareStatement(sql);

  } // end prepareStatement

  /**
   * Creates a <code>CallableStatement</code> object for calling
   * database stored procedures.
   *
   * @param sql a SQL statement that may contain one or more '?' parameter placeholders.
   *            Typically this  statement is a JDBC function call escape string.
   * @return a new CallableStatement object containing the pre-compiled SQL statement 
   * @exception SQLException if a database access error occurs
   */
  public CallableStatement prepareCall(String sql) throws SQLException
  {
    return conn.prepareCall(sql);

  } // end prepareCall
						
  /**
   * Converts the given SQL statement into the system's native SQL grammar.
   *
   * @param sql a SQL statement that may contain one or more '?' parameter placeholders
   * @return the native form of this statement
   * @exception SQLException if a database access error occurs
   */
  public String nativeSQL(String sql) throws SQLException
  {
    return conn.nativeSQL(sql);

  } // end nativeSQL

  /**
   * Sets this connection's auto-commit mode.
   *
   * @param autoCommit true enables auto-commit; false disables auto-commit.  
   * @exception SQLException if a database access error occurs
   */
  public void setAutoCommit(boolean autoCommit) throws SQLException
  {
    conn.setAutoCommit(autoCommit);

  } // end setAutoCommit

  /**
   * Gets the current auto-commit state.
   *
   * @return the current state of auto-commit mode
   * @exception SQLException if a database access error occurs
   * @see #setAutoCommit 
   */
  public boolean getAutoCommit() throws SQLException
  {
    return conn.getAutoCommit();

  } // end getAutoCommit

  /**
   * Makes all changes made since the previous
   * commit/rollback permanent and releases any database locks
   * currently held by the Connection. This method should be
   * used only when auto-commit mode has been disabled.
   *
   * @exception SQLException if a database access error occurs
   * @see #setAutoCommit 
   */
  public void commit() throws SQLException
  {
    conn.commit();

  } // end commit

  /**
   * Drops all changes made since the previous
   * commit/rollback and releases any database locks currently held
   * by this Connection. This method should be used only when auto-
   * commit has been disabled.
   *
   * @exception SQLException if a database access error occurs
   * @see #setAutoCommit 
   */
  public void rollback() throws SQLException
  {
    conn.rollback();

  } // end rollback

  /**
   * Releases a Connection's database and JDBC resources
   * immediately instead of waiting for them to be automatically released.
   *
   * @exception SQLException if a database access error occurs
   */
  public synchronized void close() throws SQLException
  {
    if (!(conn.getAutoCommit()))
      conn.rollback();
    datapool.releaseConnection(conn);
    conn = null;

  } // end close

  /**
   * Tests to see if a Connection is closed.
   *
   * @return true if the connection is closed; false if it's still open
   * @exception SQLException if a database access error occurs
   */
  public boolean isClosed() throws SQLException
  {
    return (conn==null) ? true : conn.isClosed();

  } // end isClosed

  /**
   * Gets the metadata regarding this connection's database.
   *
   * @return a DatabaseMetaData object for this Connection 
   * @exception SQLException if a database access error occurs
   */
  public DatabaseMetaData getMetaData() throws SQLException
  {
    return conn.getMetaData();

  } // end getMetaData

  /**
   * Puts this connection in read-only mode as a hint to enable 
   * database optimizations.
   *
   * @param readOnly true enables read-only mode; false disables read-only mode.  
   * @exception SQLException if a database access error occurs
   */
  public void setReadOnly(boolean readOnly)
  { // do nothing
  } // end setReadOnly

  /**
   * Tests to see if the connection is in read-only mode.
   *
   * @return true if connection is read-only and false otherwise
   * @exception SQLException if a database access error occurs
   */
  public boolean isReadOnly()
  {
    return false;

  } // end isReadOnly

  /**
   * Sets a catalog name in order to select 	
   * a subspace of this Connection's database in which to work.
   * If the driver does not support catalogs, it will
   * silently ignore this request.
   *
   * @exception SQLException if a database access error occurs
   */
  public void setCatalog(String catalog)
  { // do nothing
  } // end setCatalog

  /**
   * Returns the Connection's current catalog name.
   *
   * @return the current catalog name or null
   * @exception SQLException if a database access error occurs
   */
  public String getCatalog()
  {
    return null;

  } // end getCatalog

  /**
   * Attempts to change the transaction
   * isolation level to the one given.
   * The constants defined in the interface <code>Connection</code>
   * are the possible transaction isolation levels.
   *
   * @param level one of the TRANSACTION_* isolation values with the exception of TRANSACTION_NONE;
   *              some databases may not support other values
   * @exception SQLException if a database access error occurs
   * @see DatabaseMetaData#supportsTransactionIsolationLevel 
   */
  public void setTransactionIsolation(int level)
  { // do nothing
  } // end setTransactionIsolation

  /**
   * Gets this Connection's current transaction isolation level.
   *
   * @return the current TRANSACTION_* mode value
   * @exception SQLException if a database access error occurs
   */
  public int getTransactionIsolation() throws SQLException
  {
    return conn.getTransactionIsolation();

  } // end getTransactionIsolation

  /**
   * Returns the first warning reported by calls on this Connection.
   *
   * @return the first SQLWarning or null 
   * @exception SQLException if a database access error occurs
   */
  public SQLWarning getWarnings() throws SQLException
  {
    return conn.getWarnings();

  } // end getWarnings

  /**
   * Clears all warnings reported for this <code>Connection</code> object.	
   * After a call to this method, the method <code>getWarnings</code>
   * returns null until a new warning is reported for this Connection.  
   *
   * @exception SQLException if a database access error occurs
   */
  public void clearWarnings() throws SQLException
  {
    conn.clearWarnings();

  } // end clearWarnings

  /**
   * Creates a <code>Statement</code> object that will generate
   * <code>ResultSet</code> objects with the given type and concurrency.
   *
   * @param resultSetType a result set type; see ResultSet.TYPE_XXX
   * @param resultSetConcurrency a concurrency type; see ResultSet.CONCUR_XXX
   * @return a new Statement object 
   * @exception SQLException if a database access error occurs
   * @since 1.2
   * @see <a href="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
   */
  public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
  {
    return conn.createStatement(resultSetType,resultSetConcurrency);

  } // end createStatement

  /**
   * Creates a <code>PreparedStatement</code> object that will generate
   * <code>ResultSet</code> objects with the given type and concurrency.
   * This method is the same as the <code>prepareStatement</code> method
   * above, but it allows the default result set
   * type and result set concurrency type to be overridden.
   *
   * @param resultSetType a result set type; see ResultSet.TYPE_XXX
   * @param resultSetConcurrency a concurrency type; see ResultSet.CONCUR_XXX
   * @return a new PreparedStatement object containing the pre-compiled SQL statement 
   * @exception SQLException if a database access error occurs
   * @since 1.2
   * @see <a href="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
   */
  public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
      throws SQLException
  {
    return conn.prepareStatement(sql,resultSetType,resultSetConcurrency);

  } // end prepareStatement

  /**
   * Creates a <code>CallableStatement</code> object that will generate
   * <code>ResultSet</code> objects with the given type and concurrency.
   * This method is the same as the <code>prepareCall</code> method
   * above, but it allows the default result set
   * type and result set concurrency type to be overridden.
   *
   * @param resultSetType a result set type; see ResultSet.TYPE_XXX
   * @param resultSetConcurrency a concurrency type; see ResultSet.CONCUR_XXX
   * @return a new CallableStatement object containing the pre-compiled SQL statement 
   * @exception SQLException if a database access error occurs
   * @since 1.2
   * @see <a href="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
   */
  public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
      throws SQLException
  {
    return conn.prepareCall(sql,resultSetType,resultSetConcurrency);

  } // end prepareCall

  /**
   * Gets the type map object associated with this connection.
   * Unless the application has added an entry to the type map,
   * the map returned will be empty.
   *
   * @return the <code>java.util.Map</code> object associated with this <code>Connection</code> object
   * @since 1.2
   * @see <a href="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
   */
  public java.util.Map getTypeMap() throws SQLException
  {
    return conn.getTypeMap();

  } // end getTypeMap

  /**
   * Installs the given type map as the type map for
   * this connection.  The type map will be used for the
   * custom mapping of SQL structured types and distinct types.
   *
   * @param map the <code>java.util.Map</code> object to install
   *        as the replacement for this <code>Connection</code>
   *        object's default type map
   * @since 1.2
   * @see <a href="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a>
   */
  public void setTypeMap(java.util.Map map) throws SQLException
  {
    conn.setTypeMap(map);

  } // end setTypeMap

  /**
   * Changes the holdability of <code>ResultSet</code> objects created using this <code>Connection</code>
   * object to the given holdability.
   *
   * @param holdability a <code>ResultSet</code> holdability constant; one of
   *                    <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
   *                    <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
   * @exception java.sql.SQLException if a database access occurs, the given parameter is not a <code>ResultSet</code>
   *            constant indicating holdability, or the given holdability is not supported
   * @since 1.4
   * @see #getHoldability()
   * @see java.sql.ResultSet
   */
  public void setHoldability(int holdability) throws SQLException
  {
    conn.setHoldability(holdability);

  } // end setHoldability

  /**
   * Retrieves the current holdability of <code>ResultSet</code> objects created using this <code>Connection</code>
   * object.
   *
   * @return the holdability, one of <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
   *         <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
   * @exception java.sql.SQLException if a database access occurs
   * @since 1.4
   * @see #setHoldability(int)
   * @see java.sql.ResultSet
   */
  public int getHoldability() throws SQLException
  {
    return conn.getHoldability();

  } // end getHoldability

  /**
   * Creates an unnamed savepoint in the current transaction and returns the new <code>Savepoint</code> object that
   * represents it.
   *
   * @return the new <code>Savepoint</code> object
   * @exception java.sql.SQLException if a database access error occurs or this <code>Connection</code> object is
   *            currently in auto-commit mode
   * @since 1.4
   * @see java.sql.Savepoint
   */
  public Savepoint setSavepoint() throws SQLException
  {
    return conn.setSavepoint();

  } // end setSavepoint

  /**
   * Creates a savepoint with the given name in the current transaction and returns the new <code>Savepoint</code>
   * object that represents it.
   * 
   * @param name a <code>String</code> containing the name of the savepoint
   * @return the new <code>Savepoint</code> object
   * @exception java.sql.SQLException if a database access error occurs or this <code>Connection</code> object is
   *            currently in auto-commit mode
   * @since 1.4
   * @see java.sql.Savepoint
   */
  public Savepoint setSavepoint(String name) throws SQLException
  {
    return conn.setSavepoint(name);

  } // end setSavepoint

  /**
   * Undoes all changes made after the given <code>Savepoint</code> object was set.<p>
   * This method should be used only when auto-commit has been disabled. 
   *
   * @param savepoint the <code>Savepoint</code> object to roll back to
   * @exception java.sql.SQLException if a database access error occurs, the Z<code>Savepoint</code> object is
   *            no longer valid, or this <code>Connection</code> object is currently in auto-commit mode
   * @since 1.4
   * @see java.sql.Savepoint
   * @see #rollback()
   */
  public void rollback(Savepoint savepoint) throws SQLException
  {
    conn.rollback(savepoint);

  } // end rollback

  /**
   * Removes the given <code>Savepoint</code> object from the current transaction. Any reference to the savepoint
   * after it have been removed will cause an <code>SQLException</code> to be thrown.
   *
   * @param savepoint the <code>Savepoint</code> object to be removed
   * @exception java.sql.SQLException if a database access error occurs or the given <code>Savepoint</code> object
   *            is not a valid savepoint in the current transaction
   * @since 1.4
   */
  public void releaseSavepoint(Savepoint savepoint) throws SQLException
  {
    conn.releaseSavepoint(savepoint);

  } // end releaseSavepoint

  /**
   * Creates a <code>Statement</code> object that will generate <code>ResultSet</code> objects with the given type,
   * concurrency, and holdability. This method is the same as the <code>createStatement</code> method above, but it
   * allows the default result set type, concurrency, and holdability to be overridden.
   *
   * @param resultSetType one of the following <code>ResultSet</code> constants:
   *                      <code>ResultSet.TYPE_FORWARD_ONLY</code>, <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>,
   *                      or <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
   * @param resultSetConcurrency one of the following <code>ResultSet</code> constants:
   *                             <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>
   * @return a new <code>Statement</code> object that will generate <code>ResultSet</code> objects with the given
   *         type, concurrency, and holdability
   * @exception java.sql.SQLException if a database access error occurs or the given parameters are not
   *            <code>ResultSet</code> constants indicating type, concurrency, and holdability
   * @since 1.4
   * @see java.sql.ResultSet
   */
  public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
      throws SQLException
  {
    return conn.createStatement(resultSetType,resultSetConcurrency,resultSetHoldability);

  } // end createStatement

  /**
   * Creates a <code>PreparedStatement</code> object that will generate <code>ResultSet</code> objects with the
   * given type, concurrency, and holdability.<p>
   * This method is the same as the <code>prepareStatement</code> method above, but it allows the default result
   * set type, concurrency, and holdability to be overridden. 
   *
   * @param sql a <code>String</code> object that is the SQL statement to be sent to the database; may contain one
   *            or more ? IN parameters
   * @param resultSetType one of the following <code>ResultSet</code> constants:
   *                      <code>ResultSet.TYPE_FORWARD_ONLY</code>, <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>,
   *                      or <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
   * @param resultSetConcurrency one of the following <code>ResultSet</code> constants:
   *                             <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>
   * @return a new <code>PreparedStatement</code> object, containing the pre-compiled SQL statement, that will
   *         generate <code>ResultSet</code> objects with the given type, concurrency, and holdability
   * @exception java.sql.SQLException if a database access error occurs or the given parameters are not
   *            <code>ResultSet</code> constants indicating type, concurrency, and holdability
   * @since 1.4
   * @see java.sql.ResultSet
   */
  public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
					    int resultSetHoldability) throws SQLException
  {
    return conn.prepareStatement(sql,resultSetType,resultSetConcurrency,resultSetHoldability);

  } // end prepareStatement

  /**
   * Creates a <code>CallableStatement</code> object that will generate <code>ResultSet</code> objects with the
   * given type and concurrency. This method is the same as the <code>prepareCall</code> method above, but it
   * allows the default result set type, result set concurrency type and holdability to be overridden.
   *
   * @param sql a <code>String</code> object that is the SQL statement to be sent to the database; may contain one
   *            or more ? parameters
   * @param resultSetType one of the following <code>ResultSet</code> constants:
   *                      <code>ResultSet.TYPE_FORWARD_ONLY</code>, <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>,
   *                      or <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
   * @param resultSetConcurrency one of the following <code>ResultSet</code> constants:
   *                             <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>
   * @return a new <code>CallableStatement</code> object, containing the pre-compiled SQL statement, that will
   *         generate <code>ResultSet</code> objects with the given type, concurrency, and holdability
   * @exception java.sql.SQLException if a database access error occurs or the given parameters are not
   *            <code>ResultSet</code> constants indicating type, concurrency, and holdability
   * @since 1.4
   * @see java.sql.ResultSet
   */
  public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,
				       int resultSetHoldability) throws SQLException
  {
    return conn.prepareCall(sql,resultSetType,resultSetConcurrency,resultSetHoldability);

  } // end prepareCall

  /**
   * Creates a default <code>PreparedStatement</code> object that has the capability to retrieve auto-generated
   * keys. The given constant tells the driver whether it should make auto-generated keys available for retrieval.
   * This parameter is ignored if the SQL statement is not an <code>INSERT</code> statement.<p>
   * <b>Note:</b> This method is optimized for handling parametric SQL statements that benefit from precompilation.
   * If the driver supports precompilation, the method <code>prepareStatement</code> will send the statement to the
   * database for precompilation. Some drivers may not support precompilation. In this case, the statement may not
   * be sent to the database until the <code>PreparedStatement</code> object is executed. This has no direct effect
   * on users; however, it does affect which methods throw certain <code>SQLException</code>s.<p>
   * Result sets created using the returned <code>PreparedStatement</code> object will by default be type
   * <code>TYPE_FORWARD_ONLY</code> and have a concurrency level of <code>CONCUR_READ_ONLY</code>.
   *
   * @param sql an SQL statement that may contain one or more '?' IN parameter placeholders
   * @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>
   * @return a new <code>PreparedStatement</code> object, containing the pre-compiled SQL statement, that will
   *         generate <code>ResultSet</code> objects with the given type, concurrency, and holdability
   * @exception java.sql.SQLException if a database access error occurs or the given parameter is not a
   *            <code>Statement</code> constant indicating whether auto-generated keys should be returned
   * @since 1.4
   */
  public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
  {
    return conn.prepareStatement(sql,autoGeneratedKeys);

  } // end prepareStatement

  /**
   * Creates a default <code>PreparedStatement</code> object capable of returning the auto-generated keys designated
   * by the given array. This array contains the indexes of the columns in the target table that contain the
   * auto-generated keys that should be made available. This array is ignored if the SQL statement is not an
   * <code>INSERT</code> statement.<p>
   * An SQL statement with or without IN parameters can be pre-compiled and stored in a <code>PreparedStatement</code>
   * object. This object can then be used to efficiently execute this statement multiple times.<p>
   * <b>Note:</b> This method is optimized for handling parametric SQL statements that benefit from precompilation.
   * If the driver supports precompilation, the method <code>prepareStatement</code> will send the statement to the
   * database for precompilation. Some drivers may not support precompilation. In this case, the statement may not
   * be sent to the database until the <code>PreparedStatement</code> object is executed. This has no direct effect
   * on users; however, it does affect which methods throw certain <code>SQLException</code>s.<p>
   * Result sets created using the returned <code>PreparedStatement</code> object will by default be type
   * <code>TYPE_FORWARD_ONLY</code> and have a concurrency level of <code>CONCUR_READ_ONLY</code>.
   *
   * @param sql an SQL statement that may contain one or more '?' IN parameter placeholders
   * @param columnIndexes an array of column indexes indicating the columns that should be returned from the
   *                      inserted row or rows
   * @return a new <code>PreparedStatement</code> object, containing the pre-compiled statement, that is capable
   *         of returning the auto-generated keys designated by the given array of column indexes
   * @exception java.sql.SQLException if a database access error occurs
   * @since 1.4
   */
  public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
  {
    return conn.prepareStatement(sql,columnIndexes);

  } // end prepareStatement

  /**
   * Creates a default <code>PreparedStatement</code> object capable of returning the auto-generated keys designated
   * by the given array. This array contains the names of the columns in the target table that contain the
   * auto-generated keys that should be returned. This array is ignored if the SQL statement is not an
   * <code>INSERT</code> statement.<p>
   * An SQL statement with or without IN parameters can be pre-compiled and stored in a <code>PreparedStatement</code>
   * object. This object can then be used to efficiently execute this statement multiple times.<p>
   * <b>Note:</b> This method is optimized for handling parametric SQL statements that benefit from precompilation.
   * If the driver supports precompilation, the method <code>prepareStatement</code> will send the statement to the
   * database for precompilation. Some drivers may not support precompilation. In this case, the statement may not
   * be sent to the database until the <code>PreparedStatement</code> object is executed. This has no direct effect
   * on users; however, it does affect which methods throw certain <code>SQLException</code>s.<p>
   * Result sets created using the returned <code>PreparedStatement</code> object will by default be type
   * <code>TYPE_FORWARD_ONLY</code> and have a concurrency level of <code>CONCUR_READ_ONLY</code>.
   *
   * @param sql an SQL statement that may contain one or more '?' IN parameter placeholders
   * @param columnNames an array of column names indicating the columns that should be returned from the inserted
   *                    row or rows
   * @return a new <code>PreparedStatement</code> object, containing the pre-compiled statement, that is capable
   *         of returning the auto-generated keys designated by the given array of column names
   * @exception java.sql.SQLException if a database access error occurs
   * @since 1.4
   */
  public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
  {
    return conn.prepareStatement(sql,columnNames);

  } // end prepareStatement

  /*--------------------------------------------------------------------------------
   * External operations
   *--------------------------------------------------------------------------------
   */

  Connection getRealConnection()
  {
    return conn;

  } // end getRealConnection

} // end class WrappedConnection
