You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pc...@apache.org on 2006/06/28 21:34:40 UTC

svn commit: r417856 [5/22] - in /incubator/openjpa/trunk/openjpa-lib: java/ main/ main/java/ main/java/org/apache/openjpa/lib/ant/ main/java/org/apache/openjpa/lib/conf/ main/java/org/apache/openjpa/lib/jdbc/ main/java/org/apache/openjpa/lib/log/ main/...

Modified: incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java?rev=417856&r1=415364&r2=417856&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java Wed Jun 28 12:34:33 2006
@@ -15,1236 +15,780 @@
  */
 package org.apache.openjpa.lib.jdbc;
 
+import org.apache.openjpa.lib.util.*;
+import org.apache.openjpa.lib.util.Closeable;
 
 import java.io.*;
+
 import java.math.*;
+
 import java.net.*;
+
 import java.sql.*;
-import java.sql.Date;		
-import java.util.*;
+import java.sql.Date;
 
-import org.apache.openjpa.lib.util.Closeable; 
+import java.util.*;
 
 
 /**
- *	<p>{@link CallableStatement} that delegates to an internal statement.</p>
+ *  <p>{@link CallableStatement} that delegates to an internal statement.</p>
  *
- *	@author		Abe White
+ *  @author Abe White
  */
-public class DelegatingCallableStatement 
-	implements CallableStatement, Closeable
-{
-	private final CallableStatement 			_stmnt;
-	private final DelegatingCallableStatement	_del;
-	private final Connection					_conn;
-
-
-	public DelegatingCallableStatement (CallableStatement stmnt, 
-		Connection conn)
-	{
-		_conn = conn;
-		_stmnt = stmnt;
-		if (_stmnt instanceof DelegatingCallableStatement)
-			_del = (DelegatingCallableStatement) _stmnt;
-		else
-			_del = null;
-	}
-
-
-	private ResultSet wrapResult (boolean wrap, ResultSet rs)
-	{
-		if (!wrap)
-			return rs;
-
-		// never wrap null
-		if (rs == null)
-			return null;
-
-		return new DelegatingResultSet (rs, this);
-	}
-
-
-	/**
-	 *	Return the wrapped statement.
-	 */
-	public CallableStatement getDelegate ()
-	{
-		return _stmnt;
-	}
-
-
-	/**
-	 *	Return the base underlying data store statement.
-	 */
-	public CallableStatement getInnermostDelegate ()
-	{
-		return (_del == null) ? _stmnt : _del.getInnermostDelegate ();
-	}
-
-
-	public int hashCode ()
-	{
-		return getInnermostDelegate ().hashCode ();
-	}
-
-
-	public boolean equals (Object other)
-	{
-		if (other == this)
-			return true;
-		if (other instanceof DelegatingCallableStatement)
-			other = ((DelegatingCallableStatement) other).
-				getInnermostDelegate ();
-		return getInnermostDelegate ().equals (other);
-	}
-
-
-	public String toString ()
-	{
-		StringBuffer buf = new StringBuffer ("prepstmnt ").append (hashCode ());
-		appendInfo (buf);
-		return buf.toString ();
-	}
-
-
-	protected void appendInfo (StringBuffer buf)
-	{
-		if (_del != null)
-			_del.appendInfo (buf);
-	}
-
-
-    public ResultSet executeQuery (String str) 
-		throws SQLException
-	{
-		return executeQuery (true);
-	}
-
-
-	/**
- 	 *	Execute the query, with the option of not wrapping it in a
-	 *	{@link DelegatingResultSet}, which is the default.
-	 */
-	protected ResultSet executeQuery (String sql, boolean wrap)
-		throws SQLException
-	{
-		ResultSet rs;
-		if (_del != null)
-			rs = _del.executeQuery (sql, false);
-		else
-			rs = _stmnt.executeQuery (sql);
-
-		return wrapResult (wrap, rs);
-	}
-
-
-    public int executeUpdate (String str) 
-		throws SQLException
-	{
-		return _stmnt.executeUpdate (str);
-	}
-
-
-    public boolean execute (String str) 
-		throws SQLException
-	{
-		return _stmnt.execute (str);
-	}
-
-
-    public void close () 
-		throws SQLException
-	{
-		_stmnt.close ();
-	}
-
-
-    public int getMaxFieldSize () 
-		throws SQLException
-	{
-		return _stmnt.getMaxFieldSize ();
-	}
-
-
-    public void setMaxFieldSize (int i) 
-		throws SQLException
-	{
-		_stmnt.setMaxFieldSize (i);
-	}
-
-
-    public int getMaxRows () 
-		throws SQLException
-	{
-		return _stmnt.getMaxRows ();
-	}
-
-
-    public void setMaxRows (int i) 
-		throws SQLException
-	{
-		_stmnt.setMaxRows (i);
-	}
-
-
-    public void setEscapeProcessing (boolean bool) 
-		throws SQLException
-	{
-		_stmnt.setEscapeProcessing (bool);
-	}
-
-
-    public int getQueryTimeout () 
-		throws SQLException
-	{
-		return _stmnt.getQueryTimeout ();
-	}
-
-
-    public void setQueryTimeout (int i) 
-		throws SQLException
-	{
-		_stmnt.setQueryTimeout (i);
-	}
-
-
-    public void cancel () 
-		throws SQLException
-	{
-		_stmnt.cancel ();
-	}
-
-
-    public SQLWarning getWarnings () 
-		throws SQLException
-	{
-		return _stmnt.getWarnings ();
-	}
-
-
-    public void clearWarnings () 
-		throws SQLException
-	{
-		_stmnt.clearWarnings ();
-	}
-
-
-    public void setCursorName (String str) 
-		throws SQLException
-	{
-		_stmnt.setCursorName (str);
-	}
-
-
-    public ResultSet getResultSet () 
-		throws SQLException
-	{
-		return getResultSet (true);
-	}
-
-
-	/**
- 	 *	Get the last result set, with the option of not wrapping it in a
-	 *	{@link DelegatingResultSet}, which is the default.
-	 */
-	protected ResultSet getResultSet (boolean wrap)
-		throws SQLException
-	{
-		ResultSet rs;
-		if (_del != null)
-			rs = _del.getResultSet (false);
-		else
-			rs = _stmnt.getResultSet ();
-
-		return wrapResult (wrap, rs);
-	}
-
-
-    public int getUpdateCount () 
-		throws SQLException
-	{
-		return _stmnt.getUpdateCount ();
-	}
-
-
-    public boolean getMoreResults () 
-		throws SQLException
-	{
-		return _stmnt.getMoreResults ();
-	}
-
-
-    public void setFetchDirection (int i) 
-		throws SQLException
-	{
-		_stmnt.setFetchDirection (i);
-	}
-
-
-    public int getFetchDirection () 
-		throws SQLException
-	{
-		return _stmnt.getFetchDirection ();
-	}
-
-
-    public void setFetchSize (int i) 
-		throws SQLException
-	{
-		_stmnt.setFetchSize (i);
-	}
-
-
-    public int getFetchSize () 
-		throws SQLException
-	{
-		return _stmnt.getFetchSize ();
-	}
-
-
-    public int getResultSetConcurrency () 
-		throws SQLException
-	{
-		return _stmnt.getResultSetConcurrency ();
-	}
-
-
-    public int getResultSetType () 
-		throws SQLException
-	{
-		return _stmnt.getResultSetType ();
-	}
-
-
-    public void addBatch (String str) 
-		throws SQLException
-	{
-		_stmnt.addBatch (str);
-	}
-
-
-    public void clearBatch () 
-		throws SQLException
-	{
-		_stmnt.clearBatch ();
-	}
-
-
-    public int[] executeBatch ()
-		throws SQLException
-	{
-		return _stmnt.executeBatch ();
-	}
-
-
-    public Connection getConnection () 
-		throws SQLException
-	{
-		return _conn;
-	}
-
-
-	public ResultSet executeQuery () 
-		throws SQLException
-	{
-		return executeQuery (true);
-	}
-
-
-	/**
- 	 *	Execute the query, with the option of not wrapping it in a
-	 *	{@link DelegatingResultSet}, which is the default.
-	 */
-	protected ResultSet executeQuery (boolean wrap)
-		throws SQLException
-	{
-		ResultSet rs;
-		if (_del != null)
-			rs = _del.executeQuery (false);
-		else
-			rs = _stmnt.executeQuery ();
-
-		return wrapResult (wrap, rs);
-	}
-
-
-	public int executeUpdate  () 
-		throws SQLException
-	{
-		return _stmnt.executeUpdate ();
-	}
-
-
-	public void setNull (int i1, int i2) 
-		throws SQLException
-	{
-		_stmnt.setNull (i1, i2);
-	}
-
-
-	public void setBoolean (int i, boolean b) 
-		throws SQLException
-	{
-		_stmnt.setBoolean (i, b);
-	}
-
-
-	public void setByte (int i, byte b) 
-		throws SQLException
-	{
-		_stmnt.setByte (i, b);
-	}
-
-
-	public void setShort (int i, short s) 
-		throws SQLException
-	{
-		_stmnt.setShort (i, s);
-	}
-
-
-	public void setInt (int i1, int i2) 
-		throws SQLException
-	{
-		_stmnt.setInt (i1, i2);
-	}
-
-
-	public void setLong (int i, long l) 
-		throws SQLException
-	{
-		_stmnt.setLong (i, l);
-	}
-
-
-	public void setFloat (int i, float f) 
-		throws SQLException
-	{
-		_stmnt.setFloat (i, f);
-	}
-
-
-	public void setDouble (int i, double d) 
-		throws SQLException
-	{
-		_stmnt.setDouble (i, d);
-	}
-
-
-	public void setBigDecimal (int i, BigDecimal bd) 
-		throws SQLException
-	{
-		_stmnt.setBigDecimal (i, bd);
-	}
-
-
-	public void setString (int i, String s) 
-		throws SQLException
-	{
-		_stmnt.setString (i, s);
-	}
-
-
-	public void setBytes (int i, byte[] b) 
-		throws SQLException
-	{
-		_stmnt.setBytes (i, b);
-	}
-
-
-	public void setDate (int i, Date d) 
-		throws SQLException
-	{
-		_stmnt.setDate (i, d);
-	}
-
-
-	public void setTime (int i, Time t) 
-		throws SQLException
-	{
-		_stmnt.setTime (i, t);
-	}
-
-
-	public void setTimestamp (int i, Timestamp t) 
-		throws SQLException
-	{
-		_stmnt.setTimestamp (i, t);
-	}
-
-
-	public void setAsciiStream (int i1, InputStream is, int i2) 
-		throws SQLException
-	{
-		_stmnt.setAsciiStream (i1, is, i2);
-	}
-
-
-	public void setUnicodeStream (int i1, InputStream is, int i2) 
-		throws SQLException
-	{
-		_stmnt.setUnicodeStream (i1, is, i2);
-	}
-
-
-	public void setBinaryStream (int i1, InputStream is, int i2) 
-		throws SQLException
-	{
-		_stmnt.setBinaryStream (i1, is, i2);
-	}
-
-
-    public void clearParameters () 
-		throws SQLException
-	{
-		_stmnt.clearParameters ();
-	}
-
-
-	public void setObject (int i1, Object o, int i2, int i3) 
-		throws SQLException
-	{
-		_stmnt.setObject (i1, o, i2, i3);
-	}
-
-
-	public void setObject (int i1, Object o, int i2)
-		throws SQLException
-	{
-		_stmnt.setObject (i1, o, i2);
-	}
-
-
-	public void setObject (int i, Object o) 
-		throws SQLException
-	{
-		_stmnt.setObject (i, o);
-	}
-
-
-    public boolean execute () 
-		throws SQLException
-	{
-		return _stmnt.execute ();
-	}
-
-
-    public void addBatch () 
-		throws SQLException
-	{
-		_stmnt.addBatch ();
-	}
-
-
-	public void setCharacterStream (int i1, Reader r, int i2)
-		throws SQLException
-	{
-		_stmnt.setCharacterStream (i1, r, i2);
-	}
-
-
-	public void setRef (int i, Ref r) 
-		throws SQLException
-	{
-		_stmnt.setRef (i, r);
-	}
-
-
-	public void setBlob (int i, Blob b) 
-		throws SQLException
-	{
-		_stmnt.setBlob (i, b);
-	}
-
-
-	public void setClob (int i, Clob c) 
-		throws SQLException
-	{
-		_stmnt.setClob (i, c);
-	}
-
-
-	public void setArray (int i, Array a) 
-		throws SQLException
-	{
-		_stmnt.setArray (i, a);
-	}
-
-
-    public ResultSetMetaData getMetaData () 
-		throws SQLException
-	{
-		return _stmnt.getMetaData ();
-	}
-
-
-	public void setDate (int i, Date d, Calendar c) 
-		throws SQLException
-	{
-		_stmnt.setDate (i, d, c);
-	}
-
-
-	public void setTime (int i, Time t, Calendar c) 
-		throws SQLException
-	{
-		_stmnt.setTime (i, t, c);
-	}
-
-
-	public void setTimestamp (int i, Timestamp t, Calendar c) 
-		throws SQLException
-	{
-		_stmnt.setTimestamp (i, t, c);
-	}
-
-
-	public void setNull (int i1, int i2, String s) 
-		throws SQLException
-	{
-		_stmnt.setNull (i1, i2, s);
-	}
-
-
-	// JDBC 3.0 (unsupported) methods follow; these are required to be able 
-	// to compile against JDK 1.4
-
-
-	public boolean getMoreResults (int i)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public ResultSet getGeneratedKeys ()
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public int executeUpdate (String s, int i) 
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public int executeUpdate (String s, int[] ia)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public int executeUpdate (String s, String[] sa)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public boolean execute (String s, int i)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public boolean execute (String s, int[] ia)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public boolean execute (String s, String[] sa)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public int getResultSetHoldability ()
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setURL (int i, URL url)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public ParameterMetaData getParameterMetaData ()
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	/////////////////////////////
-	// CallableStatement methods
-	/////////////////////////////
-
-
-	public void registerOutParameter (int i1, int i2)
-		throws SQLException
-	{
-		_stmnt.registerOutParameter (i1, i2);
-	}
-
-
-	public void registerOutParameter (int i1, int i2, int i3)
-		throws SQLException
-	{
-		_stmnt.registerOutParameter (i1, i2, i3);
-	}
-
-
-	public boolean wasNull ()
-		throws SQLException
-	{
-		return _stmnt.wasNull ();
-	}
-
-
-	public String getString (int i)
-		throws SQLException
-	{
-		return _stmnt.getString (i);
-	}
-
-
-	public boolean getBoolean (int i)
-		throws SQLException
-	{
-		return _stmnt.getBoolean (i);
-	}
-
-
-	public byte getByte (int i)
-		throws SQLException
-	{
-		return _stmnt.getByte (i);
-	}
-
-
-	public short getShort (int i)
-		throws SQLException
-	{
-		return _stmnt.getShort (i);
-	}
-
-
-	public int getInt (int i)
-		throws SQLException
-	{
-		return _stmnt.getInt (i);
-	}
-
-
-	public long getLong (int i)
-		throws SQLException
-	{
-		return _stmnt.getLong (i);
-	}
-
-
-	public float getFloat (int i)
-		throws SQLException
-	{
-		return _stmnt.getFloat (i);
-	}
-
-
-	public double getDouble (int i)
-		throws SQLException
-	{
-		return _stmnt.getDouble (i);
-	}
-
-
-	public BigDecimal getBigDecimal (int a, int b)
-		throws SQLException
-	{
-		return _stmnt.getBigDecimal (a, b);
-	}
-
-
-	public byte[] getBytes (int i)
-		throws SQLException
-	{
-		return _stmnt.getBytes (i);
-	}
-
-
-	public Date getDate (int i)
-		throws SQLException
-	{
-		return _stmnt.getDate (i);
-	}
-
-
-	public Time getTime (int i)
-		throws SQLException
-	{
-		return _stmnt.getTime (i);
-	}
-
-
-	public Timestamp getTimestamp (int i)
-		throws SQLException
-	{
-		return _stmnt.getTimestamp (i);
-	}
-
-
-	public Object getObject (int i)
-		throws SQLException
-	{
-		return _stmnt.getObject (i);
-	}
-
-
-	public BigDecimal getBigDecimal (int i)
-		throws SQLException
-	{
-		return _stmnt.getBigDecimal (i);
-	}
-
-
-	public Object getObject (int i, Map m)
-		throws SQLException
-	{
-		return _stmnt.getObject (i, m);
-	}
-
-
-	public Ref getRef (int i)
-		throws SQLException
-	{
-		return _stmnt.getRef (i);
-	}
-
-
-	public Blob getBlob (int i)
-		throws SQLException
-	{
-		return _stmnt.getBlob (i);
-	}
-
-
-	public Clob getClob (int i)
-		throws SQLException
-	{
-		return _stmnt.getClob (i);
-	}
-
-
-	public Array getArray (int i)
-		throws SQLException
-	{
-		return _stmnt.getArray (i);
-	}
-
-
-	public Date getDate (int i, Calendar c)
-		throws SQLException
-	{
-		return _stmnt.getDate (i, c);
-	}
-
-
-	public Time getTime (int i, Calendar c)
-		throws SQLException
-	{
-		return _stmnt.getTime (i, c);
-	}
-
-
-	public Timestamp getTimestamp (int i, Calendar c)
-		throws SQLException
-	{
-		return _stmnt.getTimestamp (i, c);
-	}
-
-
-	public void registerOutParameter (int i1, int i2, String s)
-		throws SQLException
-	{
-		_stmnt.registerOutParameter (i1, i2, s);
-	}
-
-
-	// JDBC 3.0 (unsupported) methods follow; these are required to be able 
-	// to compile against JDK 1.4
-
-
-	public void registerOutParameter (String s, int i)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void registerOutParameter (String s, int i1, int i2)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void registerOutParameter (String s1, int i, String s2)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public URL getURL (int i)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setURL (String a, URL b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public URL getURL (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setNull (String a, int b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setBoolean (String a, boolean b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setByte (String a, byte b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setShort (String a, short b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setInt (String a, int b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setLong (String a, long b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setFloat (String a, float b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setDouble (String a, double b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setBigDecimal (String a, BigDecimal b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setString (String a, String b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setBytes (String a, byte[] b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setDate (String a, Date b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setTime (String a, Time b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setTimestamp (String a, Timestamp b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setAsciiStream (String a, InputStream b, int c)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setBinaryStream (String a, InputStream b, int c)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setObject (String a, Object b, int c, int d)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setObject (String a, Object b, int c)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setObject (String a, Object b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setCharacterStream (String a, Reader b, int c)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setDate (String a, Date b, Calendar c)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setTime (String a, Time b, Calendar c)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setTimestamp (String a, Timestamp b, Calendar c)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public void setNull (String a, int b, String c)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public String getString (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public boolean getBoolean (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public byte getByte (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public short getShort (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public int getInt (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public long getLong (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public float getFloat (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public double getDouble (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public byte[] getBytes (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public Date getDate (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public Time getTime (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public Timestamp getTimestamp (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public Object getObject (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public BigDecimal getBigDecimal (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public Object getObject (String a, Map b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public Ref getRef (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public Blob getBlob (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public Clob getClob (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public Array getArray (String a)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public Date getDate (String a, Calendar b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public Time getTime (String a, Calendar b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
-
-
-	public Timestamp getTimestamp (String a, Calendar b)
-		throws SQLException
-	{
-		throw new UnsupportedOperationException ();
-	}
+public class DelegatingCallableStatement implements CallableStatement,
+    Closeable {
+    private final CallableStatement _stmnt;
+    private final DelegatingCallableStatement _del;
+    private final Connection _conn;
+
+    public DelegatingCallableStatement(CallableStatement stmnt, Connection conn) {
+        _conn = conn;
+        _stmnt = stmnt;
+
+        if (_stmnt instanceof DelegatingCallableStatement) {
+            _del = (DelegatingCallableStatement) _stmnt;
+        } else {
+            _del = null;
+        }
+    }
+
+    private ResultSet wrapResult(boolean wrap, ResultSet rs) {
+        if (!wrap) {
+            return rs;
+        }
+
+        // never wrap null
+        if (rs == null) {
+            return null;
+        }
+
+        return new DelegatingResultSet(rs, this);
+    }
+
+    /**
+     *  Return the wrapped statement.
+     */
+    public CallableStatement getDelegate() {
+        return _stmnt;
+    }
+
+    /**
+     *  Return the base underlying data store statement.
+     */
+    public CallableStatement getInnermostDelegate() {
+        return (_del == null) ? _stmnt : _del.getInnermostDelegate();
+    }
+
+    public int hashCode() {
+        return getInnermostDelegate().hashCode();
+    }
+
+    public boolean equals(Object other) {
+        if (other == this) {
+            return true;
+        }
+
+        if (other instanceof DelegatingCallableStatement) {
+            other = ((DelegatingCallableStatement) other).getInnermostDelegate();
+        }
+
+        return getInnermostDelegate().equals(other);
+    }
+
+    public String toString() {
+        StringBuffer buf = new StringBuffer("prepstmnt ").append(hashCode());
+        appendInfo(buf);
+
+        return buf.toString();
+    }
+
+    protected void appendInfo(StringBuffer buf) {
+        if (_del != null) {
+            _del.appendInfo(buf);
+        }
+    }
+
+    public ResultSet executeQuery(String str) throws SQLException {
+        return executeQuery(true);
+    }
+
+    /**
+      *  Execute the query, with the option of not wrapping it in a
+     *  {@link DelegatingResultSet}, which is the default.
+     */
+    protected ResultSet executeQuery(String sql, boolean wrap)
+        throws SQLException {
+        ResultSet rs;
+
+        if (_del != null) {
+            rs = _del.executeQuery(sql, false);
+        } else {
+            rs = _stmnt.executeQuery(sql);
+        }
+
+        return wrapResult(wrap, rs);
+    }
+
+    public int executeUpdate(String str) throws SQLException {
+        return _stmnt.executeUpdate(str);
+    }
+
+    public boolean execute(String str) throws SQLException {
+        return _stmnt.execute(str);
+    }
+
+    public void close() throws SQLException {
+        _stmnt.close();
+    }
+
+    public int getMaxFieldSize() throws SQLException {
+        return _stmnt.getMaxFieldSize();
+    }
+
+    public void setMaxFieldSize(int i) throws SQLException {
+        _stmnt.setMaxFieldSize(i);
+    }
+
+    public int getMaxRows() throws SQLException {
+        return _stmnt.getMaxRows();
+    }
+
+    public void setMaxRows(int i) throws SQLException {
+        _stmnt.setMaxRows(i);
+    }
+
+    public void setEscapeProcessing(boolean bool) throws SQLException {
+        _stmnt.setEscapeProcessing(bool);
+    }
+
+    public int getQueryTimeout() throws SQLException {
+        return _stmnt.getQueryTimeout();
+    }
+
+    public void setQueryTimeout(int i) throws SQLException {
+        _stmnt.setQueryTimeout(i);
+    }
+
+    public void cancel() throws SQLException {
+        _stmnt.cancel();
+    }
+
+    public SQLWarning getWarnings() throws SQLException {
+        return _stmnt.getWarnings();
+    }
+
+    public void clearWarnings() throws SQLException {
+        _stmnt.clearWarnings();
+    }
+
+    public void setCursorName(String str) throws SQLException {
+        _stmnt.setCursorName(str);
+    }
+
+    public ResultSet getResultSet() throws SQLException {
+        return getResultSet(true);
+    }
+
+    /**
+      *  Get the last result set, with the option of not wrapping it in a
+     *  {@link DelegatingResultSet}, which is the default.
+     */
+    protected ResultSet getResultSet(boolean wrap) throws SQLException {
+        ResultSet rs;
+
+        if (_del != null) {
+            rs = _del.getResultSet(false);
+        } else {
+            rs = _stmnt.getResultSet();
+        }
+
+        return wrapResult(wrap, rs);
+    }
+
+    public int getUpdateCount() throws SQLException {
+        return _stmnt.getUpdateCount();
+    }
+
+    public boolean getMoreResults() throws SQLException {
+        return _stmnt.getMoreResults();
+    }
+
+    public void setFetchDirection(int i) throws SQLException {
+        _stmnt.setFetchDirection(i);
+    }
+
+    public int getFetchDirection() throws SQLException {
+        return _stmnt.getFetchDirection();
+    }
+
+    public void setFetchSize(int i) throws SQLException {
+        _stmnt.setFetchSize(i);
+    }
+
+    public int getFetchSize() throws SQLException {
+        return _stmnt.getFetchSize();
+    }
+
+    public int getResultSetConcurrency() throws SQLException {
+        return _stmnt.getResultSetConcurrency();
+    }
+
+    public int getResultSetType() throws SQLException {
+        return _stmnt.getResultSetType();
+    }
+
+    public void addBatch(String str) throws SQLException {
+        _stmnt.addBatch(str);
+    }
+
+    public void clearBatch() throws SQLException {
+        _stmnt.clearBatch();
+    }
+
+    public int[] executeBatch() throws SQLException {
+        return _stmnt.executeBatch();
+    }
+
+    public Connection getConnection() throws SQLException {
+        return _conn;
+    }
+
+    public ResultSet executeQuery() throws SQLException {
+        return executeQuery(true);
+    }
+
+    /**
+      *  Execute the query, with the option of not wrapping it in a
+     *  {@link DelegatingResultSet}, which is the default.
+     */
+    protected ResultSet executeQuery(boolean wrap) throws SQLException {
+        ResultSet rs;
+
+        if (_del != null) {
+            rs = _del.executeQuery(false);
+        } else {
+            rs = _stmnt.executeQuery();
+        }
+
+        return wrapResult(wrap, rs);
+    }
+
+    public int executeUpdate() throws SQLException {
+        return _stmnt.executeUpdate();
+    }
+
+    public void setNull(int i1, int i2) throws SQLException {
+        _stmnt.setNull(i1, i2);
+    }
+
+    public void setBoolean(int i, boolean b) throws SQLException {
+        _stmnt.setBoolean(i, b);
+    }
+
+    public void setByte(int i, byte b) throws SQLException {
+        _stmnt.setByte(i, b);
+    }
+
+    public void setShort(int i, short s) throws SQLException {
+        _stmnt.setShort(i, s);
+    }
+
+    public void setInt(int i1, int i2) throws SQLException {
+        _stmnt.setInt(i1, i2);
+    }
+
+    public void setLong(int i, long l) throws SQLException {
+        _stmnt.setLong(i, l);
+    }
+
+    public void setFloat(int i, float f) throws SQLException {
+        _stmnt.setFloat(i, f);
+    }
+
+    public void setDouble(int i, double d) throws SQLException {
+        _stmnt.setDouble(i, d);
+    }
+
+    public void setBigDecimal(int i, BigDecimal bd) throws SQLException {
+        _stmnt.setBigDecimal(i, bd);
+    }
+
+    public void setString(int i, String s) throws SQLException {
+        _stmnt.setString(i, s);
+    }
+
+    public void setBytes(int i, byte[] b) throws SQLException {
+        _stmnt.setBytes(i, b);
+    }
+
+    public void setDate(int i, Date d) throws SQLException {
+        _stmnt.setDate(i, d);
+    }
+
+    public void setTime(int i, Time t) throws SQLException {
+        _stmnt.setTime(i, t);
+    }
+
+    public void setTimestamp(int i, Timestamp t) throws SQLException {
+        _stmnt.setTimestamp(i, t);
+    }
+
+    public void setAsciiStream(int i1, InputStream is, int i2)
+        throws SQLException {
+        _stmnt.setAsciiStream(i1, is, i2);
+    }
+
+    public void setUnicodeStream(int i1, InputStream is, int i2)
+        throws SQLException {
+        _stmnt.setUnicodeStream(i1, is, i2);
+    }
+
+    public void setBinaryStream(int i1, InputStream is, int i2)
+        throws SQLException {
+        _stmnt.setBinaryStream(i1, is, i2);
+    }
+
+    public void clearParameters() throws SQLException {
+        _stmnt.clearParameters();
+    }
+
+    public void setObject(int i1, Object o, int i2, int i3)
+        throws SQLException {
+        _stmnt.setObject(i1, o, i2, i3);
+    }
+
+    public void setObject(int i1, Object o, int i2) throws SQLException {
+        _stmnt.setObject(i1, o, i2);
+    }
+
+    public void setObject(int i, Object o) throws SQLException {
+        _stmnt.setObject(i, o);
+    }
+
+    public boolean execute() throws SQLException {
+        return _stmnt.execute();
+    }
+
+    public void addBatch() throws SQLException {
+        _stmnt.addBatch();
+    }
+
+    public void setCharacterStream(int i1, Reader r, int i2)
+        throws SQLException {
+        _stmnt.setCharacterStream(i1, r, i2);
+    }
+
+    public void setRef(int i, Ref r) throws SQLException {
+        _stmnt.setRef(i, r);
+    }
+
+    public void setBlob(int i, Blob b) throws SQLException {
+        _stmnt.setBlob(i, b);
+    }
+
+    public void setClob(int i, Clob c) throws SQLException {
+        _stmnt.setClob(i, c);
+    }
+
+    public void setArray(int i, Array a) throws SQLException {
+        _stmnt.setArray(i, a);
+    }
+
+    public ResultSetMetaData getMetaData() throws SQLException {
+        return _stmnt.getMetaData();
+    }
+
+    public void setDate(int i, Date d, Calendar c) throws SQLException {
+        _stmnt.setDate(i, d, c);
+    }
+
+    public void setTime(int i, Time t, Calendar c) throws SQLException {
+        _stmnt.setTime(i, t, c);
+    }
+
+    public void setTimestamp(int i, Timestamp t, Calendar c)
+        throws SQLException {
+        _stmnt.setTimestamp(i, t, c);
+    }
+
+    public void setNull(int i1, int i2, String s) throws SQLException {
+        _stmnt.setNull(i1, i2, s);
+    }
+
+    // JDBC 3.0 (unsupported) methods follow; these are required to be able 
+    // to compile against JDK 1.4
+    public boolean getMoreResults(int i) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public ResultSet getGeneratedKeys() throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public int executeUpdate(String s, int i) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public int executeUpdate(String s, int[] ia) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public int executeUpdate(String s, String[] sa) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean execute(String s, int i) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean execute(String s, int[] ia) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean execute(String s, String[] sa) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public int getResultSetHoldability() throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setURL(int i, URL url) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public ParameterMetaData getParameterMetaData() throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    /////////////////////////////
+    // CallableStatement methods
+    /////////////////////////////
+    public void registerOutParameter(int i1, int i2) throws SQLException {
+        _stmnt.registerOutParameter(i1, i2);
+    }
+
+    public void registerOutParameter(int i1, int i2, int i3)
+        throws SQLException {
+        _stmnt.registerOutParameter(i1, i2, i3);
+    }
+
+    public boolean wasNull() throws SQLException {
+        return _stmnt.wasNull();
+    }
+
+    public String getString(int i) throws SQLException {
+        return _stmnt.getString(i);
+    }
+
+    public boolean getBoolean(int i) throws SQLException {
+        return _stmnt.getBoolean(i);
+    }
+
+    public byte getByte(int i) throws SQLException {
+        return _stmnt.getByte(i);
+    }
+
+    public short getShort(int i) throws SQLException {
+        return _stmnt.getShort(i);
+    }
+
+    public int getInt(int i) throws SQLException {
+        return _stmnt.getInt(i);
+    }
+
+    public long getLong(int i) throws SQLException {
+        return _stmnt.getLong(i);
+    }
+
+    public float getFloat(int i) throws SQLException {
+        return _stmnt.getFloat(i);
+    }
+
+    public double getDouble(int i) throws SQLException {
+        return _stmnt.getDouble(i);
+    }
+
+    public BigDecimal getBigDecimal(int a, int b) throws SQLException {
+        return _stmnt.getBigDecimal(a, b);
+    }
+
+    public byte[] getBytes(int i) throws SQLException {
+        return _stmnt.getBytes(i);
+    }
+
+    public Date getDate(int i) throws SQLException {
+        return _stmnt.getDate(i);
+    }
+
+    public Time getTime(int i) throws SQLException {
+        return _stmnt.getTime(i);
+    }
+
+    public Timestamp getTimestamp(int i) throws SQLException {
+        return _stmnt.getTimestamp(i);
+    }
+
+    public Object getObject(int i) throws SQLException {
+        return _stmnt.getObject(i);
+    }
+
+    public BigDecimal getBigDecimal(int i) throws SQLException {
+        return _stmnt.getBigDecimal(i);
+    }
+
+    public Object getObject(int i, Map m) throws SQLException {
+        return _stmnt.getObject(i, m);
+    }
+
+    public Ref getRef(int i) throws SQLException {
+        return _stmnt.getRef(i);
+    }
+
+    public Blob getBlob(int i) throws SQLException {
+        return _stmnt.getBlob(i);
+    }
+
+    public Clob getClob(int i) throws SQLException {
+        return _stmnt.getClob(i);
+    }
+
+    public Array getArray(int i) throws SQLException {
+        return _stmnt.getArray(i);
+    }
+
+    public Date getDate(int i, Calendar c) throws SQLException {
+        return _stmnt.getDate(i, c);
+    }
+
+    public Time getTime(int i, Calendar c) throws SQLException {
+        return _stmnt.getTime(i, c);
+    }
+
+    public Timestamp getTimestamp(int i, Calendar c) throws SQLException {
+        return _stmnt.getTimestamp(i, c);
+    }
+
+    public void registerOutParameter(int i1, int i2, String s)
+        throws SQLException {
+        _stmnt.registerOutParameter(i1, i2, s);
+    }
+
+    // JDBC 3.0 (unsupported) methods follow; these are required to be able 
+    // to compile against JDK 1.4
+    public void registerOutParameter(String s, int i) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void registerOutParameter(String s, int i1, int i2)
+        throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void registerOutParameter(String s1, int i, String s2)
+        throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public URL getURL(int i) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setURL(String a, URL b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public URL getURL(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setNull(String a, int b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setBoolean(String a, boolean b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setByte(String a, byte b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setShort(String a, short b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setInt(String a, int b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setLong(String a, long b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setFloat(String a, float b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setDouble(String a, double b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setBigDecimal(String a, BigDecimal b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setString(String a, String b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setBytes(String a, byte[] b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setDate(String a, Date b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setTime(String a, Time b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setTimestamp(String a, Timestamp b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setAsciiStream(String a, InputStream b, int c)
+        throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setBinaryStream(String a, InputStream b, int c)
+        throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setObject(String a, Object b, int c, int d)
+        throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setObject(String a, Object b, int c) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setObject(String a, Object b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setCharacterStream(String a, Reader b, int c)
+        throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setDate(String a, Date b, Calendar c) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setTime(String a, Time b, Calendar c) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setTimestamp(String a, Timestamp b, Calendar c)
+        throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void setNull(String a, int b, String c) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public String getString(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean getBoolean(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public byte getByte(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public short getShort(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public int getInt(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public long getLong(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public float getFloat(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public double getDouble(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public byte[] getBytes(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Date getDate(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Time getTime(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Timestamp getTimestamp(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Object getObject(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public BigDecimal getBigDecimal(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Object getObject(String a, Map b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Ref getRef(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Blob getBlob(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Clob getClob(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Array getArray(String a) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Date getDate(String a, Calendar b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Time getTime(String a, Calendar b) throws SQLException {
+        throw new UnsupportedOperationException();
+    }
+
+    public Timestamp getTimestamp(String a, Calendar b)
+        throws SQLException {
+        throw new UnsupportedOperationException();
+    }
 }

Modified: incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java?rev=417856&r1=415364&r2=417856&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java Wed Jun 28 12:34:33 2006
@@ -15,11 +15,6 @@
  */
 package org.apache.openjpa.lib.jdbc;
 
-
-import java.lang.reflect.*;
-import java.sql.*;
-import java.util.*;
-
 import org.apache.commons.lang.exception.*;
 
 import org.apache.openjpa.lib.util.*;
@@ -27,725 +22,690 @@
 
 import serp.util.*;
 
+import java.io.*;
+
+import java.lang.reflect.*;
+
+import java.sql.*;
+
+import java.util.*;
+
 
 /**
- *	<p>Wrapper around an existing connection.  Subclasses can override the
- *	methods whose behavior they mean to change.  The <code>equals</code> and 
- *	<code>hashCode</code> methods pass through to the base underlying data 
- *	store connection.</p>
+ *  <p>Wrapper around an existing connection.  Subclasses can override the
+ *  methods whose behavior they mean to change.  The <code>equals</code> and
+ *  <code>hashCode</code> methods pass through to the base underlying data
+ *  store connection.</p>
  *
- *	@author		Abe White
+ *  @author Abe White
  */
-public class DelegatingConnection
-	implements Connection, Closeable
-{
-	// jdbc 3 method keys
-	private static final Object SET_HOLDABILITY         = new Object ();
-	private static final Object GET_HOLDABILITY         = new Object ();
-	private static final Object SET_SAVEPOINT_NONAME    = new Object ();
-	private static final Object SET_SAVEPOINT           = new Object ();
-	private static final Object ROLLBACK_SAVEPOINT      = new Object ();
-	private static final Object RELEASE_SAVEPOINT       = new Object ();
-	private static final Object CREATE_STATEMENT        = new Object ();
-	private static final Object PREPARE_STATEMENT       = new Object ();
-	private static final Object PREPARE_CALL            = new Object ();
-	private static final Object PREPARE_WITH_KEYS       = new Object ();
-	private static final Object PREPARE_WITH_INDEX      = new Object ();
-    private static final Object PREPARE_WITH_NAMES      = new Object ();
-
-	private static final Localizer _loc = Localizer.forPackage
-		(DelegatingConnection.class);
-
-	private static final Map _jdbc3;
-	static
-	{
-		boolean jdbc3 = false;
-		Method m = null;
-		try
-		{
-			m = Connection.class.getMethod ("setSavepoint",
-				new Class[] { String.class });
-			jdbc3 = true;
-		}
-		catch (Throwable t) {}
-
-		if (jdbc3)
-		{
-			_jdbc3 = new HashMap ();
-			_jdbc3.put (SET_SAVEPOINT, m);
-		}
-		else
-			_jdbc3 = null;
-    }
-
-	private final Connection 			_conn;
-	private final DelegatingConnection 	_del;
-
-
-	public DelegatingConnection (Connection conn)
-	{
-		_conn = conn;
-		if (conn instanceof DelegatingConnection)
-			_del = (DelegatingConnection) _conn;
-		else
-			_del = null;
-	}
-
-
-	/**
-	 *	Return the wrapped connection.
-	 */
-	public Connection getDelegate ()
-	{
-		return _conn;
-	}
-
-	
-	/**
-	 *	Return the base underlying data store connection.
-	 */
-	public Connection getInnermostDelegate ()
-	{
-		return (_del == null) ? _conn : _del.getInnermostDelegate ();
-	}
-
-
-	public int hashCode ()
-	{
-		return getInnermostDelegate ().hashCode ();
-	}
-
-
-	public boolean equals (Object other)
-	{
-		if (other == this)
-			return true;
-		if (other instanceof DelegatingConnection)
-			other = ((DelegatingConnection) other).getInnermostDelegate ();
-		return getInnermostDelegate ().equals (other);
-	}
-
-
-	public String toString ()
-	{
-		StringBuffer buf = new StringBuffer ("conn ").append (hashCode ());
-		appendInfo (buf);
-		return buf.toString ();
-	}
-
-
-	protected void appendInfo (StringBuffer buf)
-	{
-		if (_del != null)
-			_del.appendInfo (buf);
-	}
-
-
-	public Statement createStatement () 
-		throws SQLException
-	{
-		return createStatement (true);
-	}
-
-
-	/**
- 	 *	Create a statement, with the option of not wrapping it in a
-	 *	{@link DelegatingStatement}, which is the default.
-	 */
-	protected Statement createStatement (boolean wrap)
-		throws SQLException
-	{
-		Statement stmnt;
-		if (_del != null)
-			stmnt = _del.createStatement (false);
-		else
-			stmnt = _conn.createStatement ();
-		if (wrap)
-			stmnt = new DelegatingStatement (stmnt, this);
-		return stmnt;
-	}
-
-
-	public PreparedStatement prepareStatement (String str) 
-		throws SQLException
-	{
-		return prepareStatement (str, true);
-	}
-
-
-	/**
- 	 *	Prepare a statement, with the option of not wrapping it in a
-	 *	{@link DelegatingPreparedStatement}, which is the default.
-	 */
-	protected PreparedStatement prepareStatement (String str, boolean wrap) 
-		throws SQLException
-	{
-		PreparedStatement stmnt;
-		if (_del != null)
-			stmnt = _del.prepareStatement (str, false);
-		else
-			stmnt = _conn.prepareStatement (str);
-		if (wrap)
-			stmnt = new DelegatingPreparedStatement (stmnt, this);
-		return stmnt;
-	}
-
-
-	public CallableStatement prepareCall (String str) 
-		throws SQLException
-	{
-		return prepareCall (str, true);
-	}
-
-
-	/**
- 	 *	Prepare a call, with the option of not wrapping it in a
-	 *	{@link DelegatingCallableStatement}, which is the default.
-	 */
-	protected CallableStatement prepareCall (String str, boolean wrap) 
-		throws SQLException
-	{
-		CallableStatement stmnt;
-		if (_del != null)
-			stmnt = _del.prepareCall (str, false);
-		else
-			stmnt = _conn.prepareCall (str);
-		if (wrap)
-			stmnt = new DelegatingCallableStatement (stmnt, this);
-		return stmnt;
-	}
-
-
-	public String nativeSQL (String str) 
-		throws SQLException
-	{
-		return _conn.nativeSQL (str);
-	}
-
-
-	public void setAutoCommit (boolean bool) 
-		throws SQLException
-	{
-		_conn.setAutoCommit (bool);
-	}
-
-
-	public boolean getAutoCommit () 
-		throws SQLException
-	{
-		return _conn.getAutoCommit ();
-	}
-
-
-	public void commit () 
-		throws SQLException
-	{
-		_conn.commit ();
-	}
-
-
-	public void rollback () 
-		throws SQLException
-	{
-		_conn.rollback ();
-	}
-
-
-	public void close () 
-		throws SQLException
-	{
-		_conn.close ();
-	}
-
-
-	public boolean isClosed () 
-		throws SQLException
-	{
-		return _conn.isClosed ();
-	}
-
-
-	public DatabaseMetaData getMetaData () 
-		throws SQLException
-	{
-		return getMetaData (true);
-	}
-
-
-	/**
- 	 *	Return the metadata, with the option of not wrapping it in a
-	 *	{@link DelegatingDatabaseMetaData}, which is the default.
-	 */
-	protected DatabaseMetaData getMetaData (boolean wrap)
-		throws SQLException
-	{
-		DatabaseMetaData meta;
-		if (_del != null)
-			meta = _del.getMetaData (false);
-		else
-			meta = _conn.getMetaData ();
-		if (wrap)
-			meta = new DelegatingDatabaseMetaData (meta, this);
-		return meta;
-	}
-
-
-	public void setReadOnly (boolean bool) 
-		throws SQLException
-	{
-		_conn.setReadOnly (bool);
-	}
-
-
-	public boolean isReadOnly () 
-		throws SQLException
-	{
-		return _conn.isReadOnly ();
-	}
-
-
-	public void setCatalog (String str) 
-		throws SQLException
-	{
-		_conn.setCatalog (str);
-	}
-
-
-	public String getCatalog () 
-		throws SQLException
-	{
-		return _conn.getCatalog ();
-	}
-
-
-	public void setTransactionIsolation (int i) 
-		throws SQLException
-	{
-		_conn.setTransactionIsolation (i);
-	}
-
-
-	public int getTransactionIsolation () 
-		throws SQLException
-	{
-		return _conn.getTransactionIsolation ();
-	}
-
-
-	public SQLWarning getWarnings () 
-		throws SQLException
-	{
-		return _conn.getWarnings ();
-	}
-
-
-	public void clearWarnings () 
-		throws SQLException
-	{
-		_conn.clearWarnings ();
-	}
-
-
-	public Statement createStatement (int type, int concur) 
-		throws SQLException
-	{
-		return createStatement (type, concur, true);
-	}
-
-
-	/**
- 	 *	Create a statement, with the option of not wrapping it in a
-	 *	{@link DelegatingStatement}, which is the default.
-	 */
-	protected Statement createStatement (int type, int concur, boolean wrap)
-		throws SQLException
-	{
-		Statement stmnt;
-		if (_del != null)
-			stmnt = _del.createStatement (type, concur, false);
-		else
-			stmnt = _conn.createStatement (type, concur);
-		if (wrap)
-			stmnt = new DelegatingStatement (stmnt, this);
-		return stmnt;
-	}
-
-
-	public PreparedStatement prepareStatement (String str, int type,
-		int concur) 
-		throws SQLException
-	{
-		return prepareStatement (str, type, concur, true);
-	}
-
-
-	/**
- 	 *	Prepare a statement, with the option of not wrapping it in a
-	 *	{@link DelegatingPreparedStatement}, which is the default.
-	 */
-	protected PreparedStatement prepareStatement (String str, int type,
-		int concur, boolean wrap) 
-		throws SQLException
-	{
-		PreparedStatement stmnt;
-		if (_del != null)
-			stmnt = _del.prepareStatement (str, type, concur, false);
-		else
-			stmnt = _conn.prepareStatement (str, type, concur);
-		if (wrap)
-			stmnt = new DelegatingPreparedStatement (stmnt, this);
-		return stmnt;
-	}
-
-
-	public CallableStatement prepareCall (String str, int type, int concur) 
-		throws SQLException
-	{
-		return prepareCall (str, type, concur, true);
-	}
-
-
-	/**
- 	 *	Prepare a call, with the option of not wrapping it in a
-	 *	{@link DelegatingCallableStatement}, which is the default.
-	 */
-	protected CallableStatement prepareCall (String str, int type, int concur, 
-		boolean wrap) 
-		throws SQLException
-	{
-		CallableStatement stmnt;
-		if (_del != null)
-			stmnt = _del.prepareCall (str, type, concur, false);
-		else
-			stmnt = _conn.prepareCall (str, type, concur);
-		if (wrap)
-			stmnt = new DelegatingCallableStatement (stmnt, this);
-		return stmnt;
-	}
-
-
-	public Map getTypeMap () 
-		throws SQLException
-	{
-		return _conn.getTypeMap ();
-	}
-
-
-	public void setTypeMap (Map map) 
-		throws SQLException
-	{
-		_conn.setTypeMap (map);
-	}
-
-
-	// JDBC 3.0 methods follow; these are required to be able to 
-	// compile against JDK 1.4; these methods will not work on
-	// previous JVMs
-
-
-	public void setHoldability (int holdability)
-		throws SQLException
-	{
-		assertJDBC3 ();
-		Method m = (Method) _jdbc3.get (SET_HOLDABILITY);
-		if (m == null)
-			m = createJDBC3Method (SET_HOLDABILITY, "setHoldability",
-				new Class[] {int.class});
-		invokeJDBC3 (m, new Object[] {Numbers.valueOf (holdability)});
-	}
-
-
-	public int getHoldability ()
-		throws SQLException
-	{
-		assertJDBC3 ();
-		Method m = (Method) _jdbc3.get (GET_HOLDABILITY);
-		if (m == null)
-			m = createJDBC3Method (GET_HOLDABILITY, "getHoldability", null);
-		return ((Number) invokeJDBC3 (m, null)).intValue ();
-	}
-
-
-	public Savepoint setSavepoint ()
-		throws SQLException
-	{
-		assertJDBC3 ();
-		Method m = (Method) _jdbc3.get (SET_SAVEPOINT_NONAME);
-		if (m == null)
-			m = createJDBC3Method (SET_SAVEPOINT_NONAME, "setSavepoint", null);
-		return (Savepoint) invokeJDBC3 (m, null);
-	}
-
-
-	public Savepoint setSavepoint (String savepoint)
-		throws SQLException
-	{
-		assertJDBC3 ();
-		Method m = (Method) _jdbc3.get (SET_SAVEPOINT);
-		if (m == null)
-			m = createJDBC3Method (SET_SAVEPOINT, "setSavepoint", 
-				new Class[] {String.class});
-		return (Savepoint) invokeJDBC3 (m, new Object[] {savepoint});
-	}
-
-
-	public void rollback (Savepoint savepoint)
-		throws SQLException
-	{
-		assertJDBC3 ();
-		Method m = (Method) _jdbc3.get (ROLLBACK_SAVEPOINT);
-		if (m == null)
-			m = createJDBC3Method (ROLLBACK_SAVEPOINT, "rollback", 
-				new Class[] {Savepoint.class});
-		invokeJDBC3 (m, new Object[] {savepoint});
-	}
-
-
-	public void releaseSavepoint (Savepoint savepoint)
-		throws SQLException
-	{
-		assertJDBC3 ();
-		Method m = (Method) _jdbc3.get (RELEASE_SAVEPOINT);
-		if (m == null)
-			m = createJDBC3Method (RELEASE_SAVEPOINT, "releaseSavepoint", 
-				new Class[] {Savepoint.class});
-		invokeJDBC3 (m, new Object[] {savepoint});
-	}
-
-
-	public Statement createStatement (int resultSetType,
-		int resultSetConcurrency, int resultSetHoldability)
-		throws SQLException
-	{
-		assertJDBC3 ();
-		return createStatement (resultSetType, resultSetConcurrency, 
-			resultSetHoldability, true);
-	}
-
-
-	protected Statement createStatement (int resultSetType,
-		int resultSetConcurrency, int resultSetHoldability, boolean wrap)
-		throws SQLException
-	{
-		Statement stmnt;
-		if (_del != null)
-			stmnt = _del.createStatement (resultSetType, resultSetConcurrency,
-				resultSetHoldability, false);
-		else
-		{
-			Method m = (Method) _jdbc3.get (CREATE_STATEMENT);
-			if (m == null)
-				m = createJDBC3Method (CREATE_STATEMENT, "createStatement", 
-					new Class[] {int.class, int.class, int.class});
-			stmnt = (Statement) invokeJDBC3 (m, new Object[] {
-				Numbers.valueOf (resultSetType), 
-				Numbers.valueOf (resultSetConcurrency),
-				Numbers.valueOf (resultSetHoldability)});
-		}
-		if (wrap)
-			stmnt = new DelegatingStatement (stmnt, this);
-		return stmnt;
-	}
-
-
-	public PreparedStatement prepareStatement (String sql,
-		int resultSetType, int resultSetConcurrency, int resultSetHoldability)
-		throws SQLException
-	{
-		assertJDBC3 ();
-		return prepareStatement (sql, resultSetType, resultSetConcurrency,
-			resultSetHoldability, true);
-	}
-
-
-	protected PreparedStatement prepareStatement (String sql,
-		int resultSetType, int resultSetConcurrency, int resultSetHoldability,
-		boolean wrap)
-		throws SQLException
-	{
-		PreparedStatement stmnt;
-		if (_del != null)
-			stmnt = _del.prepareStatement (sql, resultSetType, 
-				resultSetConcurrency, resultSetHoldability, false);
-		else
-		{
-			Method m = (Method) _jdbc3.get (PREPARE_STATEMENT);
-			if (m == null)
-				m = createJDBC3Method (PREPARE_STATEMENT, "prepareStatement", 
-					new Class[]{String.class, int.class, int.class, int.class});
-			stmnt = (PreparedStatement) invokeJDBC3 (m, new Object[] { sql,
-				Numbers.valueOf (resultSetType), 
-				Numbers.valueOf (resultSetConcurrency),
-				Numbers.valueOf (resultSetHoldability)});
-		}
-		if (wrap)
-			stmnt = new DelegatingPreparedStatement (stmnt, this);
-		return stmnt;
-	}
-
-
-	public CallableStatement prepareCall (String sql,
-		int resultSetType, int resultSetConcurrency, int resultSetHoldability)
-		throws SQLException
-	{
-		assertJDBC3 ();
-		return prepareCall (sql, resultSetType, resultSetConcurrency,
-			resultSetHoldability, true);
-	}
-
-
-	protected CallableStatement prepareCall (String sql, int resultSetType, 
-		int resultSetConcurrency, int resultSetHoldability, boolean wrap)
-		throws SQLException
-	{
-		CallableStatement stmnt;
-		if (_del != null)
-			stmnt = _del.prepareCall (sql, resultSetType, 
-				resultSetConcurrency, resultSetHoldability, false);
-		else
-		{
-			Method m = (Method) _jdbc3.get (PREPARE_CALL);
-			if (m == null)
-				m = createJDBC3Method (PREPARE_CALL, "prepareCall", 
-					new Class[]{String.class, int.class, int.class, int.class});
-			stmnt = (CallableStatement) invokeJDBC3 (m, new Object[] { sql,
-				Numbers.valueOf (resultSetType), 
-				Numbers.valueOf (resultSetConcurrency),
-				Numbers.valueOf (resultSetHoldability)});
-		}
-		if (wrap)
-			stmnt = new DelegatingCallableStatement (stmnt, this);
-		return stmnt;
-	}
-
-
-	public PreparedStatement prepareStatement (String sql,
-		int autoGeneratedKeys)
-		throws SQLException
-	{
-		assertJDBC3 ();
-		return prepareStatement (sql, autoGeneratedKeys, true);
-	}
-
-
-	protected PreparedStatement prepareStatement (String sql,
-		int autoGeneratedKeys, boolean wrap)
-		throws SQLException
-	{
-		PreparedStatement stmnt;
-		if (_del != null)
-			stmnt = _del.prepareStatement (sql, autoGeneratedKeys); 
-		else
-		{
-			Method m = (Method) _jdbc3.get (PREPARE_WITH_KEYS);
-			if (m == null)
-				m = createJDBC3Method (PREPARE_WITH_KEYS, "prepareStatement", 
-					new Class[] {String.class, int.class});
-			stmnt = (PreparedStatement) invokeJDBC3 (m, new Object[] { sql,
-				Numbers.valueOf (autoGeneratedKeys)});
-		}
-		if (wrap)
-			stmnt = new DelegatingPreparedStatement (stmnt, this);
-		return stmnt;
-	}
-
-
-	public PreparedStatement prepareStatement (String sql, int[] columnIndexes)
-		throws SQLException
-	{
-		assertJDBC3 ();
-		return prepareStatement (sql, columnIndexes, true);
-	}
-
-
-	protected PreparedStatement prepareStatement (String sql, 
-		int[] columnIndexes, boolean wrap)
-		throws SQLException
-	{
-		PreparedStatement stmnt;
-		if (_del != null)
-			stmnt = _del.prepareStatement (sql, columnIndexes, wrap); 
-		else
-		{
-			Method m = (Method) _jdbc3.get (PREPARE_WITH_INDEX);
-			if (m == null)
-				m = createJDBC3Method (PREPARE_WITH_INDEX, "prepareStatement", 
-					new Class[] {String.class, int[].class});
-			stmnt = (PreparedStatement) invokeJDBC3 (m, new Object[] { sql,
-				columnIndexes});
-		}
-		if (wrap)
-			stmnt = new DelegatingPreparedStatement (stmnt, this);
-		return stmnt;
-	}
-
-
-	public PreparedStatement prepareStatement (String sql, String[] columnNames)
-		throws SQLException
-	{
-		assertJDBC3 ();
-		return prepareStatement (sql, columnNames, true);
-	}
-
-
-	protected PreparedStatement prepareStatement (String sql, 
-		String[] columnNames, boolean wrap)
-		throws SQLException
-	{
-		assertJDBC3 ();
-		PreparedStatement stmnt;
-		if (_del != null)
-			stmnt = _del.prepareStatement (sql, columnNames, wrap); 
-		else
-		{
-			Method m = (Method) _jdbc3.get (PREPARE_WITH_NAMES);
-			if (m == null)
-				m = createJDBC3Method (PREPARE_WITH_NAMES, "prepareStatement", 
-					new Class[] {String.class, String[].class});
-			stmnt = (PreparedStatement) invokeJDBC3 (m, new Object[] { sql,
-				columnNames});
-		}
-		if (wrap)
-			stmnt = new DelegatingPreparedStatement (stmnt, this);
-		return stmnt;
-	}
-
-
-	private static void assertJDBC3 ()
-	{
-		if (_jdbc3 == null)
-			throw new UnsupportedOperationException (_loc.get ("not-jdbc3"));
-	}
-
-
-	private Object invokeJDBC3 (Method m, Object[] args)
-		throws SQLException
-	{
-		try
-		{
-			return m.invoke (_conn, args);
-		}
-		catch (Throwable t)
-		{
-			if (t instanceof SQLException)
-				throw (SQLException) t;
-			throw new NestableRuntimeException (_loc.get ("invoke-jdbc3"), t);
-		}
-	}
-
-
-	private static Method createJDBC3Method (Object key, String name, 
-		Class[] args)
-	{
-		try
-		{
-			Method m = Connection.class.getMethod (name, args);
-			_jdbc3.put (key, m);
-			return m;
-		}
-		catch (Throwable t)
-		{
-			throw new NestableRuntimeException (_loc.get ("error-jdbc3"), t);
-		}
-	}
+public class DelegatingConnection implements Connection, Closeable {
+    // jdbc 3 method keys
+    private static final Object SET_HOLDABILITY = new Object();
+    private static final Object GET_HOLDABILITY = new Object();
+    private static final Object SET_SAVEPOINT_NONAME = new Object();
+    private static final Object SET_SAVEPOINT = new Object();
+    private static final Object ROLLBACK_SAVEPOINT = new Object();
+    private static final Object RELEASE_SAVEPOINT = new Object();
+    private static final Object CREATE_STATEMENT = new Object();
+    private static final Object PREPARE_STATEMENT = new Object();
+    private static final Object PREPARE_CALL = new Object();
+    private static final Object PREPARE_WITH_KEYS = new Object();
+    private static final Object PREPARE_WITH_INDEX = new Object();
+    private static final Object PREPARE_WITH_NAMES = new Object();
+    private static final Localizer _loc = Localizer.forPackage(DelegatingConnection.class);
+    private static final Map _jdbc3;
+
+    static {
+        boolean jdbc3 = false;
+        Method m = null;
+
+        try {
+            m = Connection.class.getMethod("setSavepoint",
+                    new Class[] { String.class });
+            jdbc3 = true;
+        } catch (Throwable t) {
+        }
+
+        if (jdbc3) {
+            _jdbc3 = new HashMap();
+            _jdbc3.put(SET_SAVEPOINT, m);
+        } else {
+            _jdbc3 = null;
+        }
+    }
+
+    private final Connection _conn;
+    private final DelegatingConnection _del;
+
+    public DelegatingConnection(Connection conn) {
+        _conn = conn;
+
+        if (conn instanceof DelegatingConnection) {
+            _del = (DelegatingConnection) _conn;
+        } else {
+            _del = null;
+        }
+    }
+
+    /**
+     *  Return the wrapped connection.
+     */
+    public Connection getDelegate() {
+        return _conn;
+    }
+
+    /**
+     *  Return the base underlying data store connection.
+     */
+    public Connection getInnermostDelegate() {
+        return (_del == null) ? _conn : _del.getInnermostDelegate();
+    }
+
+    public int hashCode() {
+        return getInnermostDelegate().hashCode();
+    }
+
+    public boolean equals(Object other) {
+        if (other == this) {
+            return true;
+        }
+
+        if (other instanceof DelegatingConnection) {
+            other = ((DelegatingConnection) other).getInnermostDelegate();
+        }
+
+        return getInnermostDelegate().equals(other);
+    }
+
+    public String toString() {
+        StringBuffer buf = new StringBuffer("conn ").append(hashCode());
+        appendInfo(buf);
+
+        return buf.toString();
+    }
+
+    protected void appendInfo(StringBuffer buf) {
+        if (_del != null) {
+            _del.appendInfo(buf);
+        }
+    }
+
+    public Statement createStatement() throws SQLException {
+        return createStatement(true);
+    }
+
+    /**
+      *  Create a statement, with the option of not wrapping it in a
+     *  {@link DelegatingStatement}, which is the default.
+     */
+    protected Statement createStatement(boolean wrap) throws SQLException {
+        Statement stmnt;
+
+        if (_del != null) {
+            stmnt = _del.createStatement(false);
+        } else {
+            stmnt = _conn.createStatement();
+        }
+
+        if (wrap) {
+            stmnt = new DelegatingStatement(stmnt, this);
+        }
+
+        return stmnt;
+    }
+
+    public PreparedStatement prepareStatement(String str)
+        throws SQLException {
+        return prepareStatement(str, true);
+    }
+
+    /**
+      *  Prepare a statement, with the option of not wrapping it in a
+     *  {@link DelegatingPreparedStatement}, which is the default.
+     */
+    protected PreparedStatement prepareStatement(String str, boolean wrap)
+        throws SQLException {
+        PreparedStatement stmnt;
+
+        if (_del != null) {
+            stmnt = _del.prepareStatement(str, false);
+        } else {
+            stmnt = _conn.prepareStatement(str);
+        }
+
+        if (wrap) {
+            stmnt = new DelegatingPreparedStatement(stmnt, this);
+        }
+
+        return stmnt;
+    }
+
+    public CallableStatement prepareCall(String str) throws SQLException {
+        return prepareCall(str, true);
+    }
+
+    /**
+      *  Prepare a call, with the option of not wrapping it in a
+     *  {@link DelegatingCallableStatement}, which is the default.
+     */
+    protected CallableStatement prepareCall(String str, boolean wrap)
+        throws SQLException {
+        CallableStatement stmnt;
+
+        if (_del != null) {
+            stmnt = _del.prepareCall(str, false);
+        } else {
+            stmnt = _conn.prepareCall(str);
+        }
+
+        if (wrap) {
+            stmnt = new DelegatingCallableStatement(stmnt, this);
+        }
+
+        return stmnt;
+    }
+
+    public String nativeSQL(String str) throws SQLException {
+        return _conn.nativeSQL(str);
+    }
+
+    public void setAutoCommit(boolean bool) throws SQLException {
+        _conn.setAutoCommit(bool);
+    }
+
+    public boolean getAutoCommit() throws SQLException {
+        return _conn.getAutoCommit();
+    }
+
+    public void commit() throws SQLException {
+        _conn.commit();
+    }
+
+    public void rollback() throws SQLException {
+        _conn.rollback();
+    }
+
+    public void close() throws SQLException {
+        _conn.close();
+    }
+
+    public boolean isClosed() throws SQLException {
+        return _conn.isClosed();
+    }
+
+    public DatabaseMetaData getMetaData() throws SQLException {
+        return getMetaData(true);
+    }
+
+    /**
+      *  Return the metadata, with the option of not wrapping it in a
+     *  {@link DelegatingDatabaseMetaData}, which is the default.
+     */
+    protected DatabaseMetaData getMetaData(boolean wrap)
+        throws SQLException {
+        DatabaseMetaData meta;
+
+        if (_del != null) {
+            meta = _del.getMetaData(false);
+        } else {
+            meta = _conn.getMetaData();
+        }
+
+        if (wrap) {
+            meta = new DelegatingDatabaseMetaData(meta, this);
+        }
+
+        return meta;
+    }
+
+    public void setReadOnly(boolean bool) throws SQLException {
+        _conn.setReadOnly(bool);
+    }
+
+    public boolean isReadOnly() throws SQLException {
+        return _conn.isReadOnly();
+    }
+
+    public void setCatalog(String str) throws SQLException {
+        _conn.setCatalog(str);
+    }
+
+    public String getCatalog() throws SQLException {
+        return _conn.getCatalog();
+    }
+
+    public void setTransactionIsolation(int i) throws SQLException {
+        _conn.setTransactionIsolation(i);
+    }
+
+    public int getTransactionIsolation() throws SQLException {
+        return _conn.getTransactionIsolation();
+    }
+
+    public SQLWarning getWarnings() throws SQLException {
+        return _conn.getWarnings();
+    }
+
+    public void clearWarnings() throws SQLException {
+        _conn.clearWarnings();
+    }
+
+    public Statement createStatement(int type, int concur)
+        throws SQLException {
+        return createStatement(type, concur, true);
+    }
+
+    /**
+      *  Create a statement, with the option of not wrapping it in a
+     *  {@link DelegatingStatement}, which is the default.
+     */
+    protected Statement createStatement(int type, int concur, boolean wrap)
+        throws SQLException {
+        Statement stmnt;
+
+        if (_del != null) {
+            stmnt = _del.createStatement(type, concur, false);
+        } else {
+            stmnt = _conn.createStatement(type, concur);
+        }
+
+        if (wrap) {
+            stmnt = new DelegatingStatement(stmnt, this);
+        }
+
+        return stmnt;
+    }
+
+    public PreparedStatement prepareStatement(String str, int type, int concur)
+        throws SQLException {
+        return prepareStatement(str, type, concur, true);
+    }
+
+    /**
+      *  Prepare a statement, with the option of not wrapping it in a
+     *  {@link DelegatingPreparedStatement}, which is the default.
+     */
+    protected PreparedStatement prepareStatement(String str, int type,
+        int concur, boolean wrap) throws SQLException {
+        PreparedStatement stmnt;
+
+        if (_del != null) {
+            stmnt = _del.prepareStatement(str, type, concur, false);
+        } else {
+            stmnt = _conn.prepareStatement(str, type, concur);
+        }
+
+        if (wrap) {
+            stmnt = new DelegatingPreparedStatement(stmnt, this);
+        }
+
+        return stmnt;
+    }
+
+    public CallableStatement prepareCall(String str, int type, int concur)
+        throws SQLException {
+        return prepareCall(str, type, concur, true);
+    }
+
+    /**
+      *  Prepare a call, with the option of not wrapping it in a
+     *  {@link DelegatingCallableStatement}, which is the default.
+     */
+    protected CallableStatement prepareCall(String str, int type, int concur,
+        boolean wrap) throws SQLException {
+        CallableStatement stmnt;
+
+        if (_del != null) {
+            stmnt = _del.prepareCall(str, type, concur, false);
+        } else {
+            stmnt = _conn.prepareCall(str, type, concur);
+        }
+
+        if (wrap) {
+            stmnt = new DelegatingCallableStatement(stmnt, this);
+        }
+
+        return stmnt;
+    }
+
+    public Map getTypeMap() throws SQLException {
+        return _conn.getTypeMap();
+    }
+
+    public void setTypeMap(Map map) throws SQLException {
+        _conn.setTypeMap(map);
+    }
+
+    // JDBC 3.0 methods follow; these are required to be able to 
+    // compile against JDK 1.4; these methods will not work on
+    // previous JVMs
+    public void setHoldability(int holdability) throws SQLException {
+        assertJDBC3();
+
+        Method m = (Method) _jdbc3.get(SET_HOLDABILITY);
+
+        if (m == null) {
+            m = createJDBC3Method(SET_HOLDABILITY, "setHoldability",
+                    new Class[] { int.class });
+        }
+
+        invokeJDBC3(m, new Object[] { Numbers.valueOf(holdability) });
+    }
+
+    public int getHoldability() throws SQLException {
+        assertJDBC3();
+
+        Method m = (Method) _jdbc3.get(GET_HOLDABILITY);
+
+        if (m == null) {
+            m = createJDBC3Method(GET_HOLDABILITY, "getHoldability", null);
+        }
+
+        return ((Number) invokeJDBC3(m, null)).intValue();
+    }
+
+    public Savepoint setSavepoint() throws SQLException {
+        assertJDBC3();
+
+        Method m = (Method) _jdbc3.get(SET_SAVEPOINT_NONAME);
+
+        if (m == null) {
+            m = createJDBC3Method(SET_SAVEPOINT_NONAME, "setSavepoint", null);
+        }
+
+        return (Savepoint) invokeJDBC3(m, null);
+    }
+
+    public Savepoint setSavepoint(String savepoint) throws SQLException {
+        assertJDBC3();
+
+        Method m = (Method) _jdbc3.get(SET_SAVEPOINT);
+
+        if (m == null) {
+            m = createJDBC3Method(SET_SAVEPOINT, "setSavepoint",
+                    new Class[] { String.class });
+        }
+
+        return (Savepoint) invokeJDBC3(m, new Object[] { savepoint });
+    }
+
+    public void rollback(Savepoint savepoint) throws SQLException {
+        assertJDBC3();
+
+        Method m = (Method) _jdbc3.get(ROLLBACK_SAVEPOINT);
+
+        if (m == null) {
+            m = createJDBC3Method(ROLLBACK_SAVEPOINT, "rollback",
+                    new Class[] { Savepoint.class });
+        }
+
+        invokeJDBC3(m, new Object[] { savepoint });
+    }
+
+    public void releaseSavepoint(Savepoint savepoint) throws SQLException {
+        assertJDBC3();
+
+        Method m = (Method) _jdbc3.get(RELEASE_SAVEPOINT);
+
+        if (m == null) {
+            m = createJDBC3Method(RELEASE_SAVEPOINT, "releaseSavepoint",
+                    new Class[] { Savepoint.class });
+        }
+
+        invokeJDBC3(m, new Object[] { savepoint });
+    }
+
+    public Statement createStatement(int resultSetType,
+        int resultSetConcurrency, int resultSetHoldability)
+        throws SQLException {
+        assertJDBC3();
+
+        return createStatement(resultSetType, resultSetConcurrency,
+            resultSetHoldability, true);
+    }
+
+    protected Statement createStatement(int resultSetType,
+        int resultSetConcurrency, int resultSetHoldability, boolean wrap)
+        throws SQLException {
+        Statement stmnt;
+
+        if (_del != null) {
+            stmnt = _del.createStatement(resultSetType, resultSetConcurrency,
+                    resultSetHoldability, false);
+        } else {
+            Method m = (Method) _jdbc3.get(CREATE_STATEMENT);
+
+            if (m == null) {
+                m = createJDBC3Method(CREATE_STATEMENT, "createStatement",
+                        new Class[] { int.class, int.class, int.class });
+            }
+
+            stmnt = (Statement) invokeJDBC3(m,
+                    new Object[] {
+                        Numbers.valueOf(resultSetType),
+                        Numbers.valueOf(resultSetConcurrency),
+                        Numbers.valueOf(resultSetHoldability)
+                    });
+        }
+
+        if (wrap) {
+            stmnt = new DelegatingStatement(stmnt, this);
+        }
+
+        return stmnt;
+    }
+
+    public PreparedStatement prepareStatement(String sql, int resultSetType,
+        int resultSetConcurrency, int resultSetHoldability)
+        throws SQLException {
+        assertJDBC3();
+
+        return prepareStatement(sql, resultSetType, resultSetConcurrency,
+            resultSetHoldability, true);
+    }
+
+    protected PreparedStatement prepareStatement(String sql, int resultSetType,
+        int resultSetConcurrency, int resultSetHoldability, boolean wrap)
+        throws SQLException {
+        PreparedStatement stmnt;
+
+        if (_del != null) {
+            stmnt = _del.prepareStatement(sql, resultSetType,
+                    resultSetConcurrency, resultSetHoldability, false);
+        } else {
+            Method m = (Method) _jdbc3.get(PREPARE_STATEMENT);
+
+            if (m == null) {
+                m = createJDBC3Method(PREPARE_STATEMENT, "prepareStatement",
+                        new Class[] {
+                            String.class, int.class, int.class, int.class
+                        });
+            }
+
+            stmnt = (PreparedStatement) invokeJDBC3(m,
+                    new Object[] {
+                        sql, Numbers.valueOf(resultSetType),
+                        Numbers.valueOf(resultSetConcurrency),
+                        Numbers.valueOf(resultSetHoldability)
+                    });
+        }
+
+        if (wrap) {
+            stmnt = new DelegatingPreparedStatement(stmnt, this);
+        }
+
+        return stmnt;
+    }
+
+    public CallableStatement prepareCall(String sql, int resultSetType,
+        int resultSetConcurrency, int resultSetHoldability)
+        throws SQLException {
+        assertJDBC3();
+
+        return prepareCall(sql, resultSetType, resultSetConcurrency,
+            resultSetHoldability, true);
+    }
+
+    protected CallableStatement prepareCall(String sql, int resultSetType,
+        int resultSetConcurrency, int resultSetHoldability, boolean wrap)
+        throws SQLException {
+        CallableStatement stmnt;
+
+        if (_del != null) {
+            stmnt = _del.prepareCall(sql, resultSetType, resultSetConcurrency,
+                    resultSetHoldability, false);
+        } else {
+            Method m = (Method) _jdbc3.get(PREPARE_CALL);
+
+            if (m == null) {
+                m = createJDBC3Method(PREPARE_CALL, "prepareCall",
+                        new Class[] {
+                            String.class, int.class, int.class, int.class
+                        });
+            }
+
+            stmnt = (CallableStatement) invokeJDBC3(m,
+                    new Object[] {
+                        sql, Numbers.valueOf(resultSetType),
+                        Numbers.valueOf(resultSetConcurrency),
+                        Numbers.valueOf(resultSetHoldability)
+                    });
+        }
+
+        if (wrap) {
+            stmnt = new DelegatingCallableStatement(stmnt, this);
+        }
+
+        return stmnt;
+    }
+
+    public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
+        throws SQLException {
+        assertJDBC3();
+
+        return prepareStatement(sql, autoGeneratedKeys, true);
+    }
+
+    protected PreparedStatement prepareStatement(String sql,
+        int autoGeneratedKeys, boolean wrap) throws SQLException {
+        PreparedStatement stmnt;
+
+        if (_del != null) {
+            stmnt = _del.prepareStatement(sql, autoGeneratedKeys);
+        } else {
+            Method m = (Method) _jdbc3.get(PREPARE_WITH_KEYS);
+
+            if (m == null) {
+                m = createJDBC3Method(PREPARE_WITH_KEYS, "prepareStatement",
+                        new Class[] { String.class, int.class });
+            }
+
+            stmnt = (PreparedStatement) invokeJDBC3(m,
+                    new Object[] { sql, Numbers.valueOf(autoGeneratedKeys) });
+        }
+
+        if (wrap) {
+            stmnt = new DelegatingPreparedStatement(stmnt, this);
+        }
+
+        return stmnt;
+    }
+
+    public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
+        throws SQLException {
+        assertJDBC3();
+
+        return prepareStatement(sql, columnIndexes, true);
+    }
+
+    protected PreparedStatement prepareStatement(String sql,
+        int[] columnIndexes, boolean wrap) throws SQLException {
+        PreparedStatement stmnt;
+
+        if (_del != null) {
+            stmnt = _del.prepareStatement(sql, columnIndexes, wrap);
+        } else {
+            Method m = (Method) _jdbc3.get(PREPARE_WITH_INDEX);
+
+            if (m == null) {
+                m = createJDBC3Method(PREPARE_WITH_INDEX, "prepareStatement",
+                        new Class[] { String.class, int[].class });
+            }
+
+            stmnt = (PreparedStatement) invokeJDBC3(m,
+                    new Object[] { sql, columnIndexes });
+        }
+
+        if (wrap) {
+            stmnt = new DelegatingPreparedStatement(stmnt, this);
+        }
+
+        return stmnt;
+    }
+
+    public PreparedStatement prepareStatement(String sql, String[] columnNames)
+        throws SQLException {
+        assertJDBC3();
+
+        return prepareStatement(sql, columnNames, true);
+    }
+
+    protected PreparedStatement prepareStatement(String sql,
+        String[] columnNames, boolean wrap) throws SQLException {
+        assertJDBC3();
+
+        PreparedStatement stmnt;
+
+        if (_del != null) {
+            stmnt = _del.prepareStatement(sql, columnNames, wrap);
+        } else {
+            Method m = (Method) _jdbc3.get(PREPARE_WITH_NAMES);
+
+            if (m == null) {
+                m = createJDBC3Method(PREPARE_WITH_NAMES, "prepareStatement",
+                        new Class[] { String.class, String[].class });
+            }
+
+            stmnt = (PreparedStatement) invokeJDBC3(m,
+                    new Object[] { sql, columnNames });
+        }
+
+        if (wrap) {
+            stmnt = new DelegatingPreparedStatement(stmnt, this);
+        }
+
+        return stmnt;
+    }
+
+    private static void assertJDBC3() {
+        if (_jdbc3 == null) {
+            throw new UnsupportedOperationException(_loc.get("not-jdbc3"));
+        }
+    }
+
+    private Object invokeJDBC3(Method m, Object[] args)
+        throws SQLException {
+        try {
+            return m.invoke(_conn, args);
+        } catch (Throwable t) {
+            if (t instanceof SQLException) {
+                throw (SQLException) t;
+            }
+
+            throw new NestableRuntimeException(_loc.get("invoke-jdbc3"), t);
+        }
+    }
+
+    private static Method createJDBC3Method(Object key, String name,
+        Class[] args) {
+        try {
+            Method m = Connection.class.getMethod(name, args);
+            _jdbc3.put(key, m);
+
+            return m;
+        } catch (Throwable t) {
+            throw new NestableRuntimeException(_loc.get("error-jdbc3"), t);
+        }
+    }
 }

Modified: incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java?rev=417856&r1=415364&r2=417856&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java (original)
+++ incubator/openjpa/trunk/openjpa-lib/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java Wed Jun 28 12:34:33 2006
@@ -15,141 +15,116 @@
  */
 package org.apache.openjpa.lib.jdbc;
 
+import org.apache.openjpa.lib.util.*;
+import org.apache.openjpa.lib.util.Closeable;
 
 import java.io.*;
+
 import java.sql.*;
-import javax.sql.*;
 
-import org.apache.openjpa.lib.util.Closeable; 
+import javax.sql.*;
 
 
 /**
- *	<p>Wrapper around an existing data source.  Subclasses can override the
- *	methods whose behavior they mean to change.  The <code>equals</code> and 
- *	<code>hashCode</code> methods pass through to the base underlying data 
- *	store.</p>
+ *  <p>Wrapper around an existing data source.  Subclasses can override the
+ *  methods whose behavior they mean to change.  The <code>equals</code> and
+ *  <code>hashCode</code> methods pass through to the base underlying data
+ *  store.</p>
  *
- *	@author		Abe White
+ *  @author Abe White
  */
-public class DelegatingDataSource
-	implements DataSource, Closeable
-{
-	private final DataSource 			_ds;
-	private final DelegatingDataSource	_del;
-
-
-	/**
-	 *	Constructor.  Supply wrapped data source.
-	 */
-	public DelegatingDataSource (DataSource ds)
-	{
-		_ds = ds;
-
-		if (_ds instanceof DelegatingDataSource)
-			_del = (DelegatingDataSource) _ds;
-		else
-			_del = null;
-	}
-
-
-	/**
-	 *	Return the wrapped data source.
-	 */
-	public DataSource getDelegate ()
-	{
-		return _ds;
-	}
-
-
-	/**
-	 *	Return the inner-most wrapped delegate.
-	 */
-	public DataSource getInnermostDelegate ()
-	{
-		return (_del == null) ? _ds : _del.getInnermostDelegate ();
-	}
-
-
-	public int hashCode ()
-	{
-		return getInnermostDelegate ().hashCode ();
-	}
-
-
-	public boolean equals (Object other)
-	{
-		if (other == this)
-			return true;
-		if (other instanceof DelegatingDataSource)
-			other = ((DelegatingDataSource) other).getInnermostDelegate ();
-		return getInnermostDelegate ().equals (other);	
-	}
-
-
-	public String toString ()
-	{
-		StringBuffer buf = new StringBuffer ("datasource ").
-			append (hashCode ());
-		appendInfo (buf);
-		return buf.toString ();
-	}
-
-
-	protected void appendInfo (StringBuffer buf)
-	{
-		if (_del != null)
-			_del.appendInfo (buf);
-	}
-
-
-	public PrintWriter getLogWriter ()
-		throws SQLException
-	{
-		return _ds.getLogWriter ();
-	}
-
-
-    public void setLogWriter (PrintWriter out) 
-		throws SQLException
-	{
-		_ds.setLogWriter (out);
-	}
-
-
-	public int getLoginTimeout ()
-		throws SQLException
-	{
-		return _ds.getLoginTimeout ();
-	}
-
-
-    public void setLoginTimeout (int timeout)
-		throws SQLException
-	{
-		_ds.setLoginTimeout (timeout);
-	}
-
-
-	public Connection getConnection ()
-		throws SQLException
-	{
-		return _ds.getConnection ();
-	}
-
-
-	public Connection getConnection (String user, String pass)
-		throws SQLException
-	{
-		if (user == null && pass == null)
-			return _ds.getConnection ();
-		return _ds.getConnection (user, pass);
-	}
-
-
-	public void close ()
-		throws Exception
-	{
-		if (_ds instanceof Closeable)
-			((Closeable) _ds).close ();
-	}
+public class DelegatingDataSource implements DataSource, Closeable {
+    private final DataSource _ds;
+    private final DelegatingDataSource _del;
+
+    /**
+     *  Constructor.  Supply wrapped data source.
+     */
+    public DelegatingDataSource(DataSource ds) {
+        _ds = ds;
+
+        if (_ds instanceof DelegatingDataSource) {
+            _del = (DelegatingDataSource) _ds;
+        } else {
+            _del = null;
+        }
+    }
+
+    /**
+     *  Return the wrapped data source.
+     */
+    public DataSource getDelegate() {
+        return _ds;
+    }
+
+    /**
+     *  Return the inner-most wrapped delegate.
+     */
+    public DataSource getInnermostDelegate() {
+        return (_del == null) ? _ds : _del.getInnermostDelegate();
+    }
+
+    public int hashCode() {
+        return getInnermostDelegate().hashCode();
+    }
+
+    public boolean equals(Object other) {
+        if (other == this) {
+            return true;
+        }
+
+        if (other instanceof DelegatingDataSource) {
+            other = ((DelegatingDataSource) other).getInnermostDelegate();
+        }
+
+        return getInnermostDelegate().equals(other);
+    }
+
+    public String toString() {
+        StringBuffer buf = new StringBuffer("datasource ").append(hashCode());
+        appendInfo(buf);
+
+        return buf.toString();
+    }
+
+    protected void appendInfo(StringBuffer buf) {
+        if (_del != null) {
+            _del.appendInfo(buf);
+        }
+    }
+
+    public PrintWriter getLogWriter() throws SQLException {
+        return _ds.getLogWriter();
+    }
+
+    public void setLogWriter(PrintWriter out) throws SQLException {
+        _ds.setLogWriter(out);
+    }
+
+    public int getLoginTimeout() throws SQLException {
+        return _ds.getLoginTimeout();
+    }
+
+    public void setLoginTimeout(int timeout) throws SQLException {
+        _ds.setLoginTimeout(timeout);
+    }
+
+    public Connection getConnection() throws SQLException {
+        return _ds.getConnection();
+    }
+
+    public Connection getConnection(String user, String pass)
+        throws SQLException {
+        if ((user == null) && (pass == null)) {
+            return _ds.getConnection();
+        }
+
+        return _ds.getConnection(user, pass);
+    }
+
+    public void close() throws Exception {
+        if (_ds instanceof Closeable) {
+            ((Closeable) _ds).close();
+        }
+    }
 }