bayard 2002/11/10 12:52:32 Added: dbutils/src/java/org/apache/commons/dbutils/driver CallableStatementWrapper.java ConnectionWrapper.java DriverWrapper.java PreparedStatementWrapper.java ResultSetWrapper.java StatementWrapper.java Log: A do-nothing driver wrapper. ResultSetWrapper is not compilable yet, but I want to share across machines and make sure I hav e a backup available. Revision Changes Path 1.1 jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/driver/CallableStatementWrapper.java Index: CallableStatementWrapper.java =================================================================== package org.apache.commons.dbutils.driver; import java.sql.Connection; import java.sql.CallableStatement; import java.sql.PreparedStatement; import java.sql.SQLException; import java.math.BigDecimal; import java.sql.Date; import java.sql.Time; import java.sql.Timestamp; import java.util.Map; import java.sql.Ref; import java.sql.Blob; import java.sql.Clob; import java.sql.Array; import java.util.Calendar; public class CallableStatementWrapper extends PreparedStatementWrapper implements CallableStatement { private CallableStatement call; public CallableStatementWrapper(CallableStatement call, Connection conn) { super(call, conn); this.call = call; } public void registerOutParameter(int n1, int n2) throws SQLException { this.call.registerOutParameter(n1, n2); } public void registerOutParameter(int n1, int n2, int n3) throws SQLException { this.call.registerOutParameter(n1, n2, n3); } public boolean wasNull() throws SQLException { return this.call.wasNull(); } public String getString(int n) throws SQLException { return getString(n); } public boolean getBoolean(int n) throws SQLException { return getBoolean(n); } public byte getByte(int n) throws SQLException { return getByte(n); } public short getShort(int n) throws SQLException { return getShort(n); } public int getInt(int n) throws SQLException { return getInt(n); } public long getLong(int n) throws SQLException { return getLong(n); } public float getFloat(int n) throws SQLException { return getFloat(n); } public double getDouble(int n) throws SQLException { return getDouble(n); } public BigDecimal getBigDecimal(int n1, int n2) throws SQLException { return getBigDecimal(n1, n2); } public byte[] getBytes(int n) throws SQLException { return getBytes(n); } public Date getDate(int n) throws SQLException { return getDate(n); } public Time getTime(int n) throws SQLException { return getTime(n); } public Timestamp getTimestamp(int n) throws SQLException { return getTimestamp(n); } public Object getObject(int n) throws SQLException { return getObject(n); } public BigDecimal getBigDecimal(int n) throws SQLException { return getBigDecimal(n); } public Object getObject(int n, Map map) throws SQLException { return getObject(n, map); } public Ref getRef(int n) throws SQLException { return getRef(n); } public Blob getBlob(int n) throws SQLException { return getBlob(n); } public Clob getClob(int n) throws SQLException { return getClob(n); } public Array getArray(int n) throws SQLException { return getArray(n); } public Date getDate(int n, Calendar calendar) throws SQLException { return getDate(n, calendar); } public Time getTime(int n, Calendar calendar) throws SQLException { return getTime(n, calendar); } public Timestamp getTimestamp(int n, Calendar calendar) throws SQLException { return getTimestamp(n, calendar); } public void registerOutParameter(int n1, int n2, String string) throws SQLException { this.call.registerOutParameter(n1, n2, string); } } 1.1 jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/driver/ConnectionWrapper.java Index: ConnectionWrapper.java =================================================================== package org.apache.commons.dbutils.driver; import java.sql.Connection; import java.sql.Statement; import java.sql.SQLException; import java.sql.PreparedStatement; import java.sql.CallableStatement; import java.sql.DatabaseMetaData; import java.sql.SQLWarning; import java.util.Map; public class ConnectionWrapper implements Connection { private Connection conn; public ConnectionWrapper(Connection conn) { this.conn = conn; } public Statement createStatement() throws SQLException { return new StatementWrapper(this.conn.createStatement(), this); } public PreparedStatement prepareStatement(String string) throws SQLException { return new PreparedStatementWrapper(this.conn.prepareStatement(string), this); } public CallableStatement prepareCall(String string) throws SQLException { return new CallableStatementWrapper(this.conn.prepareCall(string), this); } public String nativeSQL(String sql) throws SQLException { return this.conn.nativeSQL(sql); } public void setAutoCommit(boolean b) throws SQLException { this.conn.setAutoCommit(b); } public boolean getAutoCommit() throws SQLException { return this.conn.getAutoCommit(); } public void commit() throws SQLException { this.conn.commit(); } public void rollback() throws SQLException { this.conn.rollback(); } public void close() throws SQLException { this.conn.close(); } public boolean isClosed() throws SQLException { return this.conn.isClosed(); } public DatabaseMetaData getMetaData() throws SQLException { return this.conn.getMetaData(); } public void setReadOnly(boolean b) throws SQLException { this.conn.setReadOnly(b); } public boolean isReadOnly() throws SQLException { return this.conn.isReadOnly(); } public void setCatalog(String catalog) throws SQLException { this.conn.setCatalog(catalog); } public String getCatalog() throws SQLException { return this.conn.getCatalog(); } public void setTransactionIsolation(int level) throws SQLException { this.conn.setTransactionIsolation(level); } public int getTransactionIsolation() throws SQLException { return this.conn.getTransactionIsolation(); } public SQLWarning getWarnings() throws SQLException { return this.conn.getWarnings(); } public void clearWarnings() throws SQLException { this.conn.clearWarnings(); } public Statement createStatement(int n1, int n2) throws SQLException { return new StatementWrapper(this.conn.createStatement(n1, n2), this); } public PreparedStatement prepareStatement(String string, int n1, int n2) throws SQLException { return new PreparedStatementWrapper(this.conn.prepareStatement(string, n1, n2), this); } public CallableStatement prepareCall(String string, int n1, int n2) throws SQLException { return new CallableStatementWrapper(this.conn.prepareCall(string, n1, n2), this); } public Map getTypeMap() throws SQLException { return this.conn.getTypeMap(); } public void setTypeMap(Map map) throws SQLException { this.conn.setTypeMap(map); } } 1.1 jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/driver/DriverWrapper.java Index: DriverWrapper.java =================================================================== package org.apache.commons.dbutils.driver; import java.sql.Driver; import java.sql.DriverManager; import java.sql.Connection; import java.util.Properties; import java.sql.SQLException; import java.sql.DriverPropertyInfo; import org.apache.commons.dbutils.DbUtils; public class DriverWrapper implements Driver { /// Extensions need to repeat this themselves... /// Or maybe have this done automatically by ensureLoaded? /// if it recognises a driver as extending this driver? static { try { DriverWrapper wrapper = new DriverWrapper(); DriverManager.registerDriver(wrapper); } catch(SQLException sqle) { } } public Connection connect(String url, Properties properties) throws SQLException { // db://<fully.qualified.classname>/<url of database> if(!acceptsURL(url)) { throw new SQLException("URL Not supported: "+url); } // remove db:// url = url.substring(5); int idx = url.indexOf("/"); if(idx == -1) { throw new SQLException("SubDriver not supplied: "+url); } String classname = url.substring(0, idx); DbUtils.ensureLoaded(classname); url = url.substring(idx+1); Driver subDriver = DriverManager.getDriver(url); Connection conn = subDriver.connect(url, properties); ConnectionWrapper wrapper = new ConnectionWrapper(conn); return wrapper; } public boolean acceptsURL(String url) throws SQLException { return url.startsWith("db://"); } public DriverPropertyInfo[] getPropertyInfo(String url, Properties properties) throws SQLException { // db://<fully.qualified.classname>/<url of database> if(!acceptsURL(url)) { throw new SQLException("URL Not supported: "+url); } // remove db:// url = url.substring(5); int idx = url.indexOf("/"); if(idx == -1) { throw new SQLException("SubDriver not supplied: "+url); } String classname = url.substring(0, idx); DbUtils.ensureLoaded(classname); url = url.substring(idx+1); Driver subDriver = DriverManager.getDriver(url); return subDriver.getPropertyInfo(url, properties); } /// None of the next three methods can work as they don't know /// what driver we're really talking to. public int getMajorVersion() { return 1; } public int getMinorVersion() { return 0; } public boolean jdbcCompliant() { // difficult to say if we're true or false return false; } } 1.1 jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/driver/PreparedStatementWrapper.java Index: PreparedStatementWrapper.java =================================================================== package org.apache.commons.dbutils.driver; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.Statement; import java.sql.ResultSet; import java.sql.SQLException; import java.math.BigDecimal; import java.sql.Date; import java.sql.Time; import java.sql.Timestamp; import java.io.InputStream; import java.io.Reader; import java.sql.Ref; import java.sql.Blob; import java.sql.Clob; import java.sql.Array; import java.sql.ResultSetMetaData; import java.util.Calendar; public class PreparedStatementWrapper extends StatementWrapper implements PreparedStatement { private PreparedStatement prep; public PreparedStatementWrapper(PreparedStatement prep, Connection conn) { super(prep, conn); this.prep = prep; } public ResultSet executeQuery() throws SQLException { return wrap(this.prep.executeQuery()); } public int executeUpdate() throws SQLException { return this.prep.executeUpdate(); } public void setNull(int idx, int type) throws SQLException { this.prep.setNull(idx, type); } public void setBoolean(int idx, boolean b) throws SQLException { this.prep.setBoolean(idx, b); } public void setByte(int idx, byte b) throws SQLException { this.prep.setByte(idx, b); } public void setShort(int idx, short s) throws SQLException { this.prep.setShort(idx, s); } public void setInt(int idx, int i) throws SQLException { this.prep.setInt(idx, i); } public void setLong(int idx, long l) throws SQLException { this.prep.setLong(idx, l); } public void setFloat(int idx, float f) throws SQLException { this.prep.setFloat(idx, f); } public void setDouble(int idx, double d) throws SQLException { this.prep.setDouble(idx, d); } public void setBigDecimal(int idx, BigDecimal bigDecimal) throws SQLException { this.prep.setBigDecimal(idx, bigDecimal); } public void setString(int idx, String string) throws SQLException { this.prep.setString(idx, string); } public void setBytes(int idx, byte[] bytes) throws SQLException { this.prep.setBytes(idx, bytes); } public void setDate(int idx, Date date) throws SQLException { this.prep.setDate(idx, date); } public void setTime(int idx, Time time) throws SQLException { this.prep.setTime(idx, time); } public void setTimestamp(int idx, Timestamp timestamp) throws SQLException { this.prep.setTimestamp(idx, timestamp); } public void setAsciiStream(int idx, InputStream inputStream, int n) throws SQLException { this.prep.setAsciiStream(idx, inputStream, n); } public void setUnicodeStream(int idx, InputStream inputStream, int n) throws SQLException { this.prep.setUnicodeStream(idx, inputStream, n); } public void setBinaryStream(int idx, InputStream inputStream, int n) throws SQLException { this.prep.setBinaryStream(idx, inputStream, n); } public void clearParameters() throws SQLException { this.prep.clearParameters(); } public void setObject(int idx, Object object, int n1, int n2) throws SQLException { this.prep.setObject(idx, object, n1, n2); } public void setObject(int idx, Object object, int n) throws SQLException { this.prep.setObject(idx, object, n); } public void setObject(int idx, Object object) throws SQLException { this.prep.setObject(idx, object); } public boolean execute() throws SQLException { return this.prep.execute(); } public void addBatch() throws SQLException { this.prep.addBatch(); } public void setCharacterStream(int idx, Reader reader, int n) throws SQLException { this.prep.setCharacterStream(idx, reader, n); } public void setRef(int idx, Ref ref) throws SQLException { this.prep.setRef(idx, ref); } public void setBlob(int idx, Blob blob) throws SQLException { this.prep.setBlob(idx, blob); } public void setClob(int idx, Clob clob) throws SQLException { this.prep.setClob(idx, clob); } public void setArray(int idx, Array array) throws SQLException { this.prep.setArray(idx, array); } public ResultSetMetaData getMetaData() throws SQLException { return this.prep.getMetaData(); } public void setDate(int idx, Date date, Calendar calendar) throws SQLException { this.prep.setDate(idx, date, calendar); } public void setTime(int idx, Time time, Calendar calendar) throws SQLException { this.prep.setTime(idx, time, calendar); } public void setTimestamp(int idx, Timestamp timestamp, Calendar calendar) throws SQLException { this.prep.setTimestamp(idx, timestamp, calendar); } public void setNull(int idx, int type, String string) throws SQLException { this.prep.setNull(idx, type, string); } } 1.1 jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/driver/ResultSetWrapper.java Index: ResultSetWrapper.java =================================================================== import java.sql.ResultSet; import java.sql.SQLException; import java.math.BigDecimal; import java.sql.Date; import java.sql.Time; import java.sql.Timestamp; import java.io.InputStream; import getString(java.lang.String; import java.sql.SQLWarning; import java.sql.ResultSetMetaData; import getObject(java.lang.String; import java.io.Reader; import updateBigDecimal(java.math.BigDecimal; import updateDate(java.sql.Date; import updateTime(java.sql.Time; import updateTimestamp(java.sql.Timestamp; import updateAsciiStream(java.io.InputStream; import updateBinaryStream(java.io.InputStream; import updateCharacterStream(java.io.Reader; import java.lang.String; import java.lang.Object; import java.sql.Statement; import getObject(java.util.Map; import java.sql.Ref; import java.sql.Blob; import java.sql.Clob; import java.sql.Array; import java.util.Map; import getDate(java.util.Calendar; import java.util.Calendar; import getTime(java.util.Calendar; import getTimestamp(java.util.Calendar; public class ResultSetWrapper implements ResultSet { public boolean next() throws SQLException { } public void close() throws SQLException { } public boolean wasNull() throws SQLException { } public String getString() throws SQLException { } public boolean getBoolean() throws SQLException { } public byte getByte() throws SQLException { } public short getShort() throws SQLException { } public int getInt() throws SQLException { } public long getLong() throws SQLException { } public float getFloat() throws SQLException { } public double getDouble() throws SQLException { } public BigDecimal getBigDecimal() throws SQLException { } public byte[] getBytes() throws SQLException { } public Date getDate() throws SQLException { } public Time getTime() throws SQLException { } public Timestamp getTimestamp() throws SQLException { } public InputStream getAsciiStream() throws SQLException { } public InputStream getUnicodeStream() throws SQLException { } public InputStream getBinaryStream() throws SQLException { } public String String string) throws SQLException { } public boolean getBoolean(String string) throws SQLException { } public byte getByte(String string) throws SQLException { } public short getShort(String string) throws SQLException { } public int getInt(String string) throws SQLException { } public long getLong(String string) throws SQLException { } public float getFloat(String string) throws SQLException { } public double getDouble(String string) throws SQLException { } public BigDecimal getBigDecimal(String string) throws SQLException { } public byte[] getBytes(String string) throws SQLException { } public Date getDate(String string) throws SQLException { } public Time getTime(String string) throws SQLException { } public Timestamp getTimestamp(String string) throws SQLException { } public InputStream getAsciiStream(String string) throws SQLException { } public InputStream getUnicodeStream(String string) throws SQLException { } public InputStream getBinaryStream(String string) throws SQLException { } public SQLWarning getWarnings() throws SQLException { } public void clearWarnings() throws SQLException { } public String getCursorName() throws SQLException { } public ResultSetMetaData getMetaData() throws SQLException { } public Object getObject() throws SQLException { } public Object String string) throws SQLException { } public int findColumn(String string) throws SQLException { } public Reader getCharacterStream() throws SQLException { } public Reader getCharacterStream(String string) throws SQLException { } public BigDecimal getBigDecimal() throws SQLException { } public BigDecimal getBigDecimal(String string) throws SQLException { } public boolean isBeforeFirst() throws SQLException { } public boolean isAfterLast() throws SQLException { } public boolean isFirst() throws SQLException { } public boolean isLast() throws SQLException { } public void beforeFirst() throws SQLException { } public void afterLast() throws SQLException { } public boolean first() throws SQLException { } public boolean last() throws SQLException { } public int getRow() throws SQLException { } public boolean absolute() throws SQLException { } public boolean relative() throws SQLException { } public boolean previous() throws SQLException { } public void setFetchDirection() throws SQLException { } public int getFetchDirection() throws SQLException { } public void setFetchSize() throws SQLException { } public int getFetchSize() throws SQLException { } public int getType() throws SQLException { } public int getConcurrency() throws SQLException { } public boolean rowUpdated() throws SQLException { } public boolean rowInserted() throws SQLException { } public boolean rowDeleted() throws SQLException { } public void updateNull() throws SQLException { } public void updateBoolean() throws SQLException { } public void updateByte() throws SQLException { } public void updateShort() throws SQLException { } public void updateInt() throws SQLException { } public void updateLong() throws SQLException { } public void updateFloat() throws SQLException { } public void updateDouble() throws SQLException { } public void BigDecimal bigDecimal) throws SQLException { } public void updateString(String string) throws SQLException { } public void updateBytes(byte[] byte[]) throws SQLException { } public void Date date) throws SQLException { } public void Time time) throws SQLException { } public void Timestamp timestamp) throws SQLException { } public void InputStream inputStream) throws SQLException { } public void InputStream inputStream) throws SQLException { } public void Reader reader) throws SQLException { } public void updateObject(Object object) throws SQLException { } public void updateObject(Object object) throws SQLException { } public void updateNull(String string) throws SQLException { } public void updateBoolean(String string) throws SQLException { } public void updateByte(String string) throws SQLException { } public void updateShort(String string) throws SQLException { } public void updateInt(String string) throws SQLException { } public void updateLong(String string) throws SQLException { } public void updateFloat(String string) throws SQLException { } public void updateDouble(String string) throws SQLException { } public void updateBigDecimal(String string, BigDecimal bigDecimal) throws SQLException { } public void updateString(String string, String string) throws SQLException { } public void updateBytes(String string, byte[] byte[]) throws SQLException { } public void updateDate(String string, Date date) throws SQLException { } public void updateTime(String string, Time time) throws SQLException { } public void updateTimestamp(String string, Timestamp timestamp) throws SQLException { } public void updateAsciiStream(String string, InputStream inputStream) throws SQLException { } public void updateBinaryStream(String string, InputStream inputStream) throws SQLException { } public void updateCharacterStream(String string, Reader reader) throws SQLException { } public void updateObject(String string, Object object) throws SQLException { } public void updateObject(String string, Object object) throws SQLException { } public void insertRow() throws SQLException { } public void updateRow() throws SQLException { } public void deleteRow() throws SQLException { } public void refreshRow() throws SQLException { } public void cancelRowUpdates() throws SQLException { } public void moveToInsertRow() throws SQLException { } public void moveToCurrentRow() throws SQLException { } public Statement getStatement() throws SQLException { } public Object Map map) throws SQLException { } public Ref getRef() throws SQLException { } public Blob getBlob() throws SQLException { } public Clob getClob() throws SQLException { } public Array getArray() throws SQLException { } public Object String string, Map map) throws SQLException { } public Ref getRef(String string) throws SQLException { } public Blob getBlob(String string) throws SQLException { } public Clob getClob(String string) throws SQLException { } public Array getArray(String string) throws SQLException { } public Date Calendar calendar) throws SQLException { } public Date getDate(String string, Calendar calendar) throws SQLException { } public Time Calendar calendar) throws SQLException { } public Time getTime(String string, Calendar calendar) throws SQLException { } public Timestamp Calendar calendar) throws SQLException { } public Timestamp getTimestamp(String string, Calendar calendar) throws SQLException { } } 1.1 jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/driver/StatementWrapper.java Index: StatementWrapper.java =================================================================== package org.apache.commons.dbutils.driver; import java.sql.Statement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.SQLWarning; import java.sql.Connection; public class StatementWrapper implements Statement { private Statement statement; private Connection connection; public StatementWrapper(Statement statement, Connection conn) { this.statement = statement; this.connection = connection; } public ResultSet executeQuery(String sql) throws SQLException { return wrap(this.statement.executeQuery(sql)); } public int executeUpdate(String string) throws SQLException { return this.statement.executeUpdate(string); } public void close() throws SQLException { this.statement.close(); } public int getMaxFieldSize() throws SQLException { return this.statement.getMaxFieldSize(); } public void setMaxFieldSize(int n) throws SQLException { this.statement.setMaxFieldSize(n); } public int getMaxRows() throws SQLException { return this.statement.getMaxRows(); } public void setMaxRows(int n) throws SQLException { this.statement.setMaxRows(n); } public void setEscapeProcessing(boolean b) throws SQLException { this.statement.setEscapeProcessing(b); } public int getQueryTimeout() throws SQLException { return this.statement.getQueryTimeout(); } public void setQueryTimeout(int n) throws SQLException { this.statement.setQueryTimeout(n); } public void cancel() throws SQLException { this.statement.cancel(); } public SQLWarning getWarnings() throws SQLException { return this.statement.getWarnings(); } public void clearWarnings() throws SQLException { this.statement.clearWarnings(); } public void setCursorName(String string) throws SQLException { this.statement.setCursorName(string); } public boolean execute(String sql) throws SQLException { return this.statement.execute(sql); } public ResultSet getResultSet() throws SQLException { return wrap(this.statement.getResultSet()); } public int getUpdateCount() throws SQLException { return this.statement.getUpdateCount(); } public boolean getMoreResults() throws SQLException { return this.statement.getMoreResults(); } public void setFetchDirection(int n) throws SQLException { this.statement.setFetchDirection(n); } public int getFetchDirection() throws SQLException { return this.statement.getFetchDirection(); } public void setFetchSize(int n) throws SQLException { this.statement.setFetchSize(n); } public int getFetchSize() throws SQLException { return this.statement.getFetchSize(); } public int getResultSetConcurrency() throws SQLException { return this.statement.getResultSetConcurrency(); } public int getResultSetType() throws SQLException { return this.statement.getResultSetType(); } public void addBatch(String sql) throws SQLException { this.statement.addBatch(sql); } public void clearBatch() throws SQLException { this.statement.clearBatch(); } public int[] executeBatch() throws SQLException { return this.statement.executeBatch(); } public Connection getConnection() throws SQLException { return this.connection; } protected ResultSet wrap(ResultSet rs) { // return new ResultSetWrapper(rs); return rs; } }
-- To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>