diff --git src/java/com/mchange/v2/c3p0/ComboPooledDataSource.java src/java/com/mchange/v2/c3p0/ComboPooledDataSource.java index d86ff2d..7b65881 100644 --- src/java/com/mchange/v2/c3p0/ComboPooledDataSource.java +++ src/java/com/mchange/v2/c3p0/ComboPooledDataSource.java @@ -582,6 +582,21 @@ throw new IOException("Unsupported Serialized Version: " + version); } } + + public boolean isWrapperFor( Class iface ) + { + return iface.isInstance(this); + } + + public Object unwrap( Class iface ) throws SQLException + { + if (this.isWrapperFor(iface)) { + return this; + } + else { + throw new SQLException("no object found"); + } + } } //now, referenceability happens exactly the same way it does for PoolBackedDataSource diff --git src/java/com/mchange/v2/c3p0/DriverManagerDataSource.java src/java/com/mchange/v2/c3p0/DriverManagerDataSource.java index 8e604c4..7adad84 100644 --- src/java/com/mchange/v2/c3p0/DriverManagerDataSource.java +++ src/java/com/mchange/v2/c3p0/DriverManagerDataSource.java @@ -256,4 +256,19 @@ throw new IOException("Unsupported Serialized Version: " + version); } } + + public boolean isWrapperFor( Class iface ) + { + return iface.isInstance(this); + } + + public Object unwrap( Class iface ) throws SQLException + { + if (this.isWrapperFor(iface)) { + return this; + } + else { + throw new SQLException("no object found"); + } + } } diff --git src/java/com/mchange/v2/c3p0/JndiRefForwardingDataSource.java src/java/com/mchange/v2/c3p0/JndiRefForwardingDataSource.java index c1c7d47..0a0cf34 100644 --- src/java/com/mchange/v2/c3p0/JndiRefForwardingDataSource.java +++ src/java/com/mchange/v2/c3p0/JndiRefForwardingDataSource.java @@ -165,5 +165,25 @@ throw new IOException("Unsupported Serialized Version: " + version); } } + + public boolean isWrapperFor( Class iface ) throws SQLException + { + return iface.isInstance(this) || iface.isInstance(inner()); + } + + public Object unwrap( Class iface ) throws SQLException + { + if (this.isWrapperFor(iface)) { + if (iface.isInstance(this)) { + return this; + } + else { + return inner(); + } + } + else { + throw new SQLException("no object found"); + } + } } diff --git src/java/com/mchange/v2/c3p0/PoolBackedDataSource.java src/java/com/mchange/v2/c3p0/PoolBackedDataSource.java index 8520bd9..f6d93cd 100644 --- src/java/com/mchange/v2/c3p0/PoolBackedDataSource.java +++ src/java/com/mchange/v2/c3p0/PoolBackedDataSource.java @@ -23,6 +23,8 @@ package com.mchange.v2.c3p0; +import java.sql.SQLException; + import com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource; public final class PoolBackedDataSource extends AbstractPoolBackedDataSource implements PooledDataSource @@ -35,5 +37,20 @@ public PoolBackedDataSource(String configName) { super( configName ); } + + public boolean isWrapperFor( Class iface ) + { + return iface.isInstance(this); + } + + public Object unwrap( Class iface ) throws SQLException + { + if (this.isWrapperFor(iface)) { + return this; + } + else { + throw new SQLException("no object found"); + } + } } diff --git src/java/com/mchange/v2/c3p0/codegen/JdbcProxyGenerator.java src/java/com/mchange/v2/c3p0/codegen/JdbcProxyGenerator.java index 984a07d..8c736ce 100644 --- src/java/com/mchange/v2/c3p0/codegen/JdbcProxyGenerator.java +++ src/java/com/mchange/v2/c3p0/codegen/JdbcProxyGenerator.java @@ -831,7 +831,7 @@ } // end-premature-detach-debug-only! - iw.println( "throw SqlUtils.toSQLException(\042You can't operate on a closed " + getInnerTypeName() + "!!!\042, exc);"); + iw.println( "throw new IllegalStateException(SqlUtils.toSQLException(\042You can't operate on a closed " + getInnerTypeName() + "!!!\042, exc));"); } iw.downIndent(); iw.println("}"); @@ -845,10 +845,10 @@ iw.println("{"); iw.upIndent(); //iw.println( "exc.printStackTrace();" ); - iw.println( "throw parentPooledConnection.handleThrowable( exc );" ); + iw.println( "throw new RuntimeException(parentPooledConnection.handleThrowable( exc ));" ); iw.downIndent(); iw.println("}"); - iw.println("else throw SqlUtils.toSQLException( exc );"); + iw.println("else throw new RuntimeException(SqlUtils.toSQLException( exc ));"); iw.downIndent(); iw.println("}"); } diff --git src/java/com/mchange/v2/c3p0/impl/C3P0PooledConnection.java src/java/com/mchange/v2/c3p0/impl/C3P0PooledConnection.java index 78336bd..fd20ab2 100644 --- src/java/com/mchange/v2/c3p0/impl/C3P0PooledConnection.java +++ src/java/com/mchange/v2/c3p0/impl/C3P0PooledConnection.java @@ -24,6 +24,8 @@ package com.mchange.v2.c3p0.impl; import java.lang.reflect.*; +import java.io.InputStream; +import java.io.Reader; import java.sql.*; import java.util.*; import javax.sql.*; @@ -521,6 +523,7 @@ private static class StatementProxyingSetManagedResultSet extends SetManagedResultSet { private Statement proxyStatement; + private boolean closed = false; StatementProxyingSetManagedResultSet(Set activeResultSets) { super( activeResultSets ); } @@ -530,6 +533,273 @@ public Statement getStatement() throws SQLException { return (proxyStatement == null ? super.getStatement() : proxyStatement); } + + public boolean isWrapperFor( Class c ) throws SQLException + { + return c.isInstance(this) || c.isInstance(this.proxyStatement) || c.isInstance(super.getStatement()); + } + + public Object unwrap( Class c ) throws SQLException + { + if (c.isInstance(this)) { + return this; + } + else if (c.isInstance(this.proxyStatement)) { + return this.proxyStatement; + } + else if (c.isInstance(super.getStatement())) { + return super.getStatement(); + } + // should people be calling unwrap if isWrapperFor would return false? + return null; + } + + public void updateNClob( String column, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNClob( String s, Reader r, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNClob( String s, NClob nc ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNClob( int i, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNClob( int i, Reader r, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNClob( int i, NClob nc ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateClob( String s, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateClob( String s, Reader reader, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateClob( int i, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateClob( int i, Reader reader, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateBlob( String s, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateBlob( String s, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateBlob( int i, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateBlob( int i, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateCharacterStream( String s, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateCharacterStream( String s, Reader reader, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateCharacterStream( int i, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateCharacterStream( int i, Reader reader, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateBinaryStream( String s, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateBinaryStream( String s, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateBinaryStream( int i, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateBinaryStream( int i, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateAsciiStream( String s, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateAsciiStream( String s, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateAsciiStream( int i, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateAsciiStream( int i, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNCharacterStream( String s, Reader r ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNCharacterStream( String s, Reader r, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNCharacterStream( int i, Reader r ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNCharacterStream( int i, Reader r, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateSQLXML( String s, SQLXML sx ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateSQLXML( int i, SQLXML sx ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNString( String label, String value ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNString( int i, String value ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateRowId( String s, RowId x ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateRowId( int i, RowId x ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public Reader getNCharacterStream( int i ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public Reader getNCharacterStream( String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public String getNString( int i ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public String getNString( String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public SQLXML getSQLXML( int i ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public SQLXML getSQLXML( String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public NClob getNClob( int i ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public NClob getNClob( String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public RowId getRowId( String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public RowId getRowId( int i ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public synchronized void close() throws SQLException + { + closed = true; + super.close(); + } + + public boolean isClosed() + { + return closed; + } + + // stub methods - required by java.sql.ResultSet since 1.6 + public int getHoldability() + { + throw new RuntimeException(new NoSuchMethodException("stub method")); + } } /* @@ -636,6 +906,7 @@ class ProxyCallableStatement extends FilterCallableStatement implements C3P0ProxyStatement { WrapperStatementHelper wsh; + private boolean closed = false; ProxyCallableStatement(CallableStatement is) { @@ -663,7 +934,317 @@ { return wsh.doRawStatementOperation( m, target, args); } public void close() throws SQLException - { wsh.doClose(); } + { + closed = true; + wsh.doClose(); + } + + public boolean isClosed() + { + return closed; + } + + public void setPoolable( boolean poolable ) + { + // do nothing + } + + public boolean isPoolable() + { + return true; + } + + public boolean isWrapperFor( Class c ) + { + return c.isInstance(this) || c.isInstance(wsh); + } + + public Object unwrap( Class c ) + { + if (c.isInstance(this)) { + return this; + } + else if (c.isInstance(wsh)) { + return wsh; + } + // should people be calling unwrap if isWrapperFor would return false? + return null; + } + + public void setNClob( String parameter, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setNClob( String s, Reader r, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setNClob( String s, NClob nc ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setNClob( int i, Reader r ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setNClob( int i, Reader r, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setNClob( int i, NClob nc ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setBlob( String s, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setBlob( String s, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setBlob( String s, Blob b ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setBlob( int i, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setBlob( int i, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setBlob( int i, Blob b ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setClob( String s, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setClob( String s, Reader r, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setClob( String s, Clob c ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setClob( int i, Reader r ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setClob( int i, Reader r, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setClob( int i, Clob c ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setNCharacterStream( String s, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setNCharacterStream( String s, Reader r, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setNCharacterStream( int i, Reader r ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setNCharacterStream( int i, Reader r, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setCharacterStream( String s, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setCharacterStream( String s, Reader reader, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setCharacterStream( int i, Reader r ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setCharacterStream( int i, Reader r, int l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setCharacterStream( int i, Reader r, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setBinaryStream( String s, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setBinaryStream( String s, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setBinaryStream( int i, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setBinaryStream( int i, InputStream inp, int l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setBinaryStream( int i, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setAsciiStream( String s, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setAsciiStream( String s, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setAsciiStream( int i, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setAsciiStream( int i, InputStream inp, int l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setAsciiStream( int i, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setNString( String name, String value ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setNString( int i, String value ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setSQLXML( String s, SQLXML sx ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setSQLXML( int i, SQLXML sx ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setRowId( String s, RowId r ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setRowId( int i, RowId r ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public Reader getCharacterStream( String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public Reader getCharacterStream( int i ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public Reader getNCharacterStream( String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public Reader getNCharacterStream( int i ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public String getNString( String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public String getNString( int i ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public SQLXML getSQLXML( String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public SQLXML getSQLXML( int i ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public NClob getNClob( String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public NClob getNClob( int i ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public RowId getRowId( String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public RowId getRowId( int i ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } } return new ProxyCallableStatement((CallableStatement) innerStmt ); @@ -673,6 +1254,7 @@ class ProxyPreparedStatement extends FilterPreparedStatement implements C3P0ProxyStatement { WrapperStatementHelper wsh; + private boolean closed = false; ProxyPreparedStatement(PreparedStatement ps) { @@ -700,7 +1282,133 @@ { return wsh.doRawStatementOperation( m, target, args); } public void close() throws SQLException - { wsh.doClose(); } + { + closed = true; + wsh.doClose(); + } + + public boolean isClosed() + { + return closed; + } + + public boolean isWrapperFor( Class c ) + { + return c.isInstance(this) || c.isInstance(wsh); + } + + public Object unwrap( Class c ) + { + if (c.isInstance(this)) { + return this; + } + else if (c.isInstance(wsh)) { + return wsh; + } + // should people be calling unwrap if isWrapperFor would return false? + return null; + } + + public void setPoolable( boolean poolable ) + { + // do nothing + return; + } + + public boolean isPoolable() + { + return true; + } + + public void setNClob( int parameter, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setNClob( int i, Reader reader, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setNClob( int i, NClob nc ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setBlob( int i, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setBlob( int i, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setClob( int i, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setClob( int i, Reader reader, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setNCharacterStream( int i, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setNCharacterStream( int i, Reader r, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setCharacterStream( int i, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setCharacterStream( int i, Reader reader, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setBinaryStream( int i, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setBinaryStream( int i, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setAsciiStream( int i, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setAsciiStream( int i, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setSQLXML( int i, SQLXML sx ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setNString( int i, String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void setRowId( int i, RowId r ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } } return new ProxyPreparedStatement((PreparedStatement) innerStmt ); @@ -710,6 +1418,7 @@ class ProxyStatement extends FilterStatement implements C3P0ProxyStatement { WrapperStatementHelper wsh; + boolean closed = false; ProxyStatement(Statement s) { @@ -734,7 +1443,40 @@ { return wsh.doRawStatementOperation( m, target, args); } public void close() throws SQLException - { wsh.doClose(); } + { + wsh.doClose(); + closed = true; + } + + public boolean isPoolable() + { + return true; + } + + public void setPoolable( boolean poolable ) + { + // do nothing + return; + } + + public boolean isClosed() + { + return closed; + } + + public boolean isWrapperFor( Class c ) + { + return c.isInstance(this); + } + + public Object unwrap( Class c ) + { + if (this.isWrapperFor(c)) { + return this; + } + // should people be calling unwrap if isWrapperFor returns false? + return null; + } } return new ProxyStatement( innerStmt ); @@ -1187,11 +1929,15 @@ logger.log(MLevel.WARNING, "Broken Connection Close Error. ", e); } } -} +// stub methods, required by javax.sql.PooledConnection since 1.6 + public void addStatementEventListener( StatementEventListener listener ) + { + throw new NoSuchMethodError("stub method"); + } - - - - - + public void removeStatementEventListener( StatementEventListener listener ) + { + throw new NoSuchMethodError("stub method"); + } +} diff --git src/java/com/mchange/v2/c3p0/impl/C3P0PooledConnectionPoolManager.java src/java/com/mchange/v2/c3p0/impl/C3P0PooledConnectionPoolManager.java index cfe9c88..584eedc 100644 --- src/java/com/mchange/v2/c3p0/impl/C3P0PooledConnectionPoolManager.java +++ src/java/com/mchange/v2/c3p0/impl/C3P0PooledConnectionPoolManager.java @@ -23,21 +23,43 @@ package com.mchange.v2.c3p0.impl; -import java.beans.*; -import java.util.*; -import java.lang.reflect.*; -import java.sql.*; -import javax.sql.*; -import com.mchange.v2.c3p0.*; -import com.mchange.v2.c3p0.cfg.*; -import com.mchange.v2.async.*; -import com.mchange.v2.coalesce.*; -import com.mchange.v1.db.sql.*; -import com.mchange.v2.log.*; +import java.beans.BeanInfo; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.Method; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.Timer; + +import javax.sql.ConnectionPoolDataSource; +import javax.sql.PooledConnection; + +import com.mchange.v1.db.sql.ConnectionUtils; +import com.mchange.v1.db.sql.ResultSetUtils; +import com.mchange.v1.db.sql.StatementUtils; import com.mchange.v1.lang.BooleanUtils; +import com.mchange.v2.async.ThreadPoolAsynchronousRunner; +import com.mchange.v2.c3p0.C3P0Registry; +import com.mchange.v2.c3p0.ConnectionCustomizer; +import com.mchange.v2.c3p0.ConnectionTester; +import com.mchange.v2.c3p0.cfg.C3P0Config; +import com.mchange.v2.coalesce.CoalesceChecker; +import com.mchange.v2.coalesce.Coalescer; +import com.mchange.v2.coalesce.CoalescerFactory; +import com.mchange.v2.log.MLevel; +import com.mchange.v2.log.MLog; +import com.mchange.v2.log.MLogger; +import com.mchange.v2.resourcepool.BasicResourcePoolFactory; +import com.mchange.v2.resourcepool.ResourcePoolFactory; import com.mchange.v2.sql.SqlUtils; -import com.mchange.v2.resourcepool.ResourcePoolFactory; -import com.mchange.v2.resourcepool.BasicResourcePoolFactory; public final class C3P0PooledConnectionPoolManager { @@ -125,11 +147,10 @@ // after the hung thread has been cleared and replaced // (in hopes of getting the thread to terminate for // garbage collection) - timer, - threadLabel ); + timer ); } else - out = new ThreadPoolAsynchronousRunner( num_threads, true, timer, threadLabel ); + out = new ThreadPoolAsynchronousRunner( num_threads, true, timer ); return out; } diff --git src/java/com/mchange/v2/c3p0/impl/NewPooledConnection.java src/java/com/mchange/v2/c3p0/impl/NewPooledConnection.java index cc83c54..604003c 100644 --- src/java/com/mchange/v2/c3p0/impl/NewPooledConnection.java +++ src/java/com/mchange/v2/c3p0/impl/NewPooledConnection.java @@ -777,4 +777,15 @@ } } } + +// stub methods, required by javax.sql.PooledConnection since 1.6 + public void addStatementEventListener( StatementEventListener listener ) + { + throw new NoSuchMethodError("stub method"); + } + + public void removeStatementEventListener( StatementEventListener listener ) + { + throw new NoSuchMethodError("stub method"); + } } diff --git src/java/com/mchange/v2/c3p0/impl/NullStatementSetManagedResultSet.java src/java/com/mchange/v2/c3p0/impl/NullStatementSetManagedResultSet.java index 3411698..7d4be76 100644 --- src/java/com/mchange/v2/c3p0/impl/NullStatementSetManagedResultSet.java +++ src/java/com/mchange/v2/c3p0/impl/NullStatementSetManagedResultSet.java @@ -29,19 +29,289 @@ */ package com.mchange.v2.c3p0.impl; +import java.io.InputStream; +import java.io.Reader; +import java.sql.NClob; import java.sql.ResultSet; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.SQLXML; import java.sql.Statement; import java.util.Set; final class NullStatementSetManagedResultSet extends SetManagedResultSet { +private boolean closed = false; + NullStatementSetManagedResultSet(Set activeResultSets) { super( activeResultSets ); } NullStatementSetManagedResultSet(ResultSet inner, Set activeResultSets) { super( inner, activeResultSets); } + +public boolean isWrapperFor( Class c ) +{ + return c.isInstance(this); +} + +public Object unwrap( Class c ) +{ + if (c.isInstance(this)) { + return this; + } + // should people be calling unwrap when isWrapperFor would return false + return null; +} public Statement getStatement() { return null; } + +public synchronized void close() throws SQLException +{ + closed = true; + super.close(); +} + +public boolean isClosed() +{ + return closed; +} + +public void updateNClob( String column, Reader reader ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateNClob( String column, Reader reader, long l ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateNClob( String column, NClob nc ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateNClob( int i, Reader reader ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateNClob( int i, Reader reader, long l ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateNClob( int i, NClob nc ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateClob( String s, Reader reader ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateClob( String s, Reader r, long l ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateClob( int i, Reader reader ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateClob( int i, Reader r, long l ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateBlob( String s, InputStream inp ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateBlob( String s, InputStream inp, long l ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateBlob( int i, InputStream inp ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateBlob( int i, InputStream inp, long l ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateCharacterStream( String s, Reader reader ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateCharacterStream( String s, Reader reader, long l ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateCharacterStream( int i, Reader reader ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateCharacterStream( int i, Reader reader, long l ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateBinaryStream( String s, InputStream inp ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateBinaryStream( String s, InputStream inp, long l ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateBinaryStream( int i, InputStream inp ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateBinaryStream( int i, InputStream inp, long l ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateAsciiStream( String s, InputStream inp ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateAsciiStream( String s, InputStream inp, long l ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateAsciiStream( int i, InputStream inp ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateAsciiStream( int i, InputStream inp, long l ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateNCharacterStream( String s, Reader reader ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateNCharacterStream( String s, Reader reader, long l ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateNCharacterStream( int i, Reader reader ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateNCharacterStream( int i, Reader reader, long l ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateSQLXML( String s, SQLXML sx ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateSQLXML( int i, SQLXML sx ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateNString( String label, String value ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateNString( int i, String value ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateRowId( String s, RowId x ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public void updateRowId( int i, RowId x ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public Reader getNCharacterStream( int i ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public Reader getNCharacterStream( String s ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public String getNString( int i ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public String getNString( String s ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public SQLXML getSQLXML( int i ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public SQLXML getSQLXML( String s ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public NClob getNClob( int i ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public NClob getNClob( String s ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public RowId getRowId( String s ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +public RowId getRowId( int i ) throws SQLFeatureNotSupportedException +{ + throw new SQLFeatureNotSupportedException(); +} + +// stub methods - required by java.sql.ResultSet since 1.6 +public int getHoldability() +{ + throw new RuntimeException(new NoSuchMethodException("stub method")); +} } diff --git src/java/com/mchange/v2/c3p0/impl/SetManagedDatabaseMetaData.java src/java/com/mchange/v2/c3p0/impl/SetManagedDatabaseMetaData.java index 8dbdd2d..e9b16be 100644 --- src/java/com/mchange/v2/c3p0/impl/SetManagedDatabaseMetaData.java +++ src/java/com/mchange/v2/c3p0/impl/SetManagedDatabaseMetaData.java @@ -131,6 +131,54 @@ { return new NullStatementSetManagedResultSet( inner.getUDTs(a, b, c, d), activeResultSets ); } -} + + public boolean isWrapperFor( Class c ) + { + return c.isInstance(this); + } + + public Object unwrap( Class c ) + { + if (this.isWrapperFor(c)) { + return this; + } + // should people be calling unwrap if isWrapperFor would return false? + return null; + } + + // stub method required by java.sql.DatabaseMetaData since 1.6 + public ResultSet getFunctionColumns( String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern ) + { + throw new RuntimeException(new NoSuchMethodException("stub method")); + } + + public ResultSet getFunctions( String catalog, String schemaPattern, String functionNamePattern ) + { + throw new RuntimeException(new NoSuchMethodException("stub method")); + } + + public ResultSet getClientInfoProperties() + { + throw new RuntimeException(new NoSuchMethodException("stub method")); + } + + public boolean autoCommitFailureClosesAllResultSets() + { + throw new RuntimeException(new NoSuchMethodException("stub method")); + } + + public boolean supportsStoredFunctionsUsingCallSyntax() + { + throw new RuntimeException(new NoSuchMethodException("stub method")); + } + public ResultSet getSchemas( String catalog, String schemaPattern ) + { + throw new RuntimeException(new NoSuchMethodException("stub method")); + } + public RowIdLifetime getRowIdLifetime() + { + throw new RuntimeException(new NoSuchMethodException("stub method")); + } +} diff --git src/java/com/mchange/v2/c3p0/impl/SnatchFromSetResultSet.java src/java/com/mchange/v2/c3p0/impl/SnatchFromSetResultSet.java index a0fb051..cada2b1 100644 --- src/java/com/mchange/v2/c3p0/impl/SnatchFromSetResultSet.java +++ src/java/com/mchange/v2/c3p0/impl/SnatchFromSetResultSet.java @@ -24,6 +24,8 @@ package com.mchange.v2.c3p0.impl; import java.sql.*; +import java.io.InputStream; +import java.io.Reader; import java.util.Set; import com.mchange.v2.sql.filter.FilterResultSet; @@ -38,6 +40,27 @@ { this.inner = inner; activeResultSets.add( inner ); + } + + public boolean isWrapperFor( Class c ) + { + return c.isInstance(this) || c.isInstance(this.inner) || c.isInstance(this.activeResultSets); + } + + public Object unwrap( Class c ) + { + if (c.isInstance(this)) { + return this; + } + else if (c.isInstance(this.inner)) { + return this.inner; + } + else if (c.isInstance(this.activeResultSets)) { + return this.activeResultSets; + } + + // should people be calling unwrap when isWrapperFor would return false? + return null; } public synchronized void close() throws SQLException @@ -46,4 +69,245 @@ activeResultSets.remove( inner ); inner = null; } + + public boolean isClosed() + { + return (inner == null); + } + + public void updateNClob( String column, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNClob( String s, Reader r, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNClob( String s, NClob nc ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNClob( int i, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNClob( int i, Reader r, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNClob( int i, NClob nc ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateClob( String s, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateClob( String s, Reader reader, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateClob( int i, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateClob( int i, Reader reader, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateBlob( String s, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateBlob( String s, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateBlob( int i, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateBlob( int i, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateCharacterStream( String s, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateCharacterStream( String s, Reader reader, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateCharacterStream( int i, Reader reader ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateCharacterStream( int i, Reader reader, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateBinaryStream( String s, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateBinaryStream( String s, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateBinaryStream( int i, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateBinaryStream( int i, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateAsciiStream( String s, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateAsciiStream( String s, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateAsciiStream( int i, InputStream inp ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateAsciiStream( int i, InputStream inp, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNCharacterStream( String s, Reader r ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNCharacterStream( String s, Reader r, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNCharacterStream( int i, Reader r ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNCharacterStream( int i, Reader r, long l ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateSQLXML( String s, SQLXML sx ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateSQLXML( int i, SQLXML sx ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNString( String label, String value ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateNString( int i, String value ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateRowId( String s, RowId x ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public void updateRowId( int i, RowId x ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public Reader getNCharacterStream( int i ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public Reader getNCharacterStream( String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public String getNString( int i ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public String getNString( String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public SQLXML getSQLXML( int i ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public SQLXML getSQLXML( String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public NClob getNClob( int i ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public NClob getNClob( String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public RowId getRowId( String s ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public RowId getRowId( int i ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + // stub methods - required by java.sql.ResultSet since 1.6 + public int getHoldability() + { + throw new RuntimeException(new NoSuchMethodException("stub method")); + } } diff --git src/java/com/mchange/v2/c3p0/test/FreezableDriverManagerDataSource.java src/java/com/mchange/v2/c3p0/test/FreezableDriverManagerDataSource.java index f386fc9..7b7a509 100644 --- src/java/com/mchange/v2/c3p0/test/FreezableDriverManagerDataSource.java +++ src/java/com/mchange/v2/c3p0/test/FreezableDriverManagerDataSource.java @@ -280,4 +280,24 @@ throw new IOException("Unsupported Serialized Version: " + version); } } + + public boolean isWrapperFor( Class iface ) throws SQLException + { + return iface.isInstance(this) || iface.isInstance(driver()); + } + + public Object unwrap( Class iface ) throws SQLException + { + if (this.isWrapperFor(iface)) { + if (iface.isInstance(this)) { + return this; + } + else { + return driver(); + } + } + else { + throw new SQLException("no object found"); + } + } } diff --git src/java/com/mchange/v2/c3p0/util/CloseReportingConnectionWrapper.java src/java/com/mchange/v2/c3p0/util/CloseReportingConnectionWrapper.java index 5d72eb1..f725ffe 100644 --- src/java/com/mchange/v2/c3p0/util/CloseReportingConnectionWrapper.java +++ src/java/com/mchange/v2/c3p0/util/CloseReportingConnectionWrapper.java @@ -24,6 +24,7 @@ package com.mchange.v2.c3p0.util; import java.sql.*; +import java.util.Properties; import com.mchange.v2.sql.filter.*; public class CloseReportingConnectionWrapper extends FilterConnection @@ -37,4 +38,73 @@ new SQLWarning("Connection.close() called!").printStackTrace(); super.close(); } + + public Struct createStruct( String typename, Object[] attrs ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public Array createArrayOf( String typename, Object[] elements ) throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public SQLXML createSQLXML() throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public NClob createNClob() throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public Blob createBlob() throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public Clob createClob() throws SQLFeatureNotSupportedException + { + throw new SQLFeatureNotSupportedException(); + } + + public boolean isWrapperFor( Class c ) + { + return c.isInstance(this); + } + + public Object unwrap( Class c ) + { + if (this.isWrapperFor(c)) { + return this; + } + return null; + } + + // stub methods required by java.sql.Connection since 1.6 + public Properties getClientInfo() + { + throw new RuntimeException(new NoSuchMethodException("stub method")); + } + + public String getClientInfo( String name ) + { + throw new RuntimeException(new NoSuchMethodException("stub method")); + } + + public void setClientInfo( Properties p ) + { + throw new RuntimeException(new NoSuchMethodException("stub method")); + } + + public void setClientInfo( String name, String value ) + { + throw new RuntimeException(new NoSuchMethodException("stub method")); + } + + public boolean isValid( int timeout ) + { + throw new RuntimeException(new NoSuchMethodException("stub method")); + } }