Last active
July 27, 2020 14:16
-
-
Save horitaku1124/c7a6a03add043149d1a6990f05f7d91f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.alternate; | |
import java.sql.*; | |
import java.util.Map; | |
import java.util.Properties; | |
import java.util.concurrent.Executor; | |
public class OConnection implements Connection { | |
private Connection altConn; | |
public OConnection(Connection alternateConnection) { | |
System.out.println("OConnection() + " + alternateConnection.getClass().getName()); | |
altConn = alternateConnection; | |
} | |
@Override | |
public Statement createStatement() throws SQLException { | |
System.out.println("OConnection().createStatement()"); | |
return altConn.createStatement(); | |
} | |
@Override | |
public PreparedStatement prepareStatement(String sql) throws SQLException { | |
System.out.println("OConnection().prepareStatement() " + sql); | |
return altConn.prepareStatement(sql); | |
} | |
@Override | |
public CallableStatement prepareCall(String sql) throws SQLException { | |
System.out.println("OConnection().prepareCall() " + sql); | |
return altConn.prepareCall(sql); | |
} | |
@Override | |
public String nativeSQL(String sql) throws SQLException { | |
System.out.println("OConnection().nativeSQL() " + sql); | |
return altConn.nativeSQL(sql); | |
} | |
@Override | |
public void setAutoCommit(boolean autoCommit) throws SQLException { | |
altConn.setAutoCommit(autoCommit); | |
} | |
@Override | |
public boolean getAutoCommit() throws SQLException { | |
return altConn.getAutoCommit(); | |
} | |
@Override | |
public void commit() throws SQLException { | |
altConn.commit(); | |
} | |
@Override | |
public void rollback() throws SQLException { | |
altConn.rollback(); | |
} | |
@Override | |
public void close() throws SQLException { | |
altConn.close(); | |
} | |
@Override | |
public boolean isClosed() throws SQLException { | |
return altConn.isClosed(); | |
} | |
@Override | |
public DatabaseMetaData getMetaData() throws SQLException { | |
return altConn.getMetaData(); | |
} | |
@Override | |
public void setReadOnly(boolean readOnly) throws SQLException { | |
altConn.setReadOnly(readOnly); | |
} | |
@Override | |
public boolean isReadOnly() throws SQLException { | |
return altConn.isReadOnly(); | |
} | |
@Override | |
public void setCatalog(String catalog) throws SQLException { | |
altConn.setCatalog(catalog); | |
} | |
@Override | |
public String getCatalog() throws SQLException { | |
return altConn.getCatalog(); | |
} | |
@Override | |
public void setTransactionIsolation(int level) throws SQLException { | |
altConn.setTransactionIsolation(level); | |
} | |
@Override | |
public int getTransactionIsolation() throws SQLException { | |
return altConn.getTransactionIsolation(); | |
} | |
@Override | |
public SQLWarning getWarnings() throws SQLException { | |
return altConn.getWarnings(); | |
} | |
@Override | |
public void clearWarnings() throws SQLException { | |
altConn.clearWarnings(); | |
} | |
@Override | |
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { | |
return altConn.createStatement(resultSetType, resultSetConcurrency); | |
} | |
@Override | |
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { | |
return altConn.prepareStatement(sql, resultSetType, resultSetConcurrency); | |
} | |
@Override | |
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { | |
return altConn.prepareCall(sql, resultSetType, resultSetConcurrency); | |
} | |
@Override | |
public Map<String, Class<?>> getTypeMap() throws SQLException { | |
return altConn.getTypeMap(); | |
} | |
@Override | |
public void setTypeMap(Map<String, Class<?>> map) throws SQLException { | |
altConn.setTypeMap(map); | |
} | |
@Override | |
public void setHoldability(int holdability) throws SQLException { | |
altConn.setHoldability(holdability); | |
} | |
@Override | |
public int getHoldability() throws SQLException { | |
return altConn.getHoldability(); | |
} | |
@Override | |
public Savepoint setSavepoint() throws SQLException { | |
return altConn.setSavepoint(); | |
} | |
@Override | |
public Savepoint setSavepoint(String name) throws SQLException { | |
return altConn.setSavepoint(); | |
} | |
@Override | |
public void rollback(Savepoint savepoint) throws SQLException { | |
altConn.rollback(); | |
} | |
@Override | |
public void releaseSavepoint(Savepoint savepoint) throws SQLException { | |
altConn.releaseSavepoint(savepoint); | |
} | |
@Override | |
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { | |
return altConn.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); | |
} | |
@Override | |
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { | |
return altConn.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); | |
} | |
@Override | |
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { | |
return altConn.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability); | |
} | |
@Override | |
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { | |
return altConn.prepareStatement(sql, autoGeneratedKeys); | |
} | |
@Override | |
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { | |
return altConn.prepareStatement(sql, columnIndexes); | |
} | |
@Override | |
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { | |
return altConn.prepareStatement(sql, columnNames); | |
} | |
@Override | |
public Clob createClob() throws SQLException { | |
return altConn.createClob(); | |
} | |
@Override | |
public Blob createBlob() throws SQLException { | |
return altConn.createBlob(); | |
} | |
@Override | |
public NClob createNClob() throws SQLException { | |
return altConn.createNClob(); | |
} | |
@Override | |
public SQLXML createSQLXML() throws SQLException { | |
return altConn.createSQLXML(); | |
} | |
@Override | |
public boolean isValid(int timeout) throws SQLException { | |
return altConn.isValid(timeout); | |
} | |
@Override | |
public void setClientInfo(String name, String value) throws SQLClientInfoException { | |
altConn.setClientInfo(name, value); | |
} | |
@Override | |
public void setClientInfo(Properties properties) throws SQLClientInfoException { | |
altConn.setClientInfo(properties); | |
} | |
@Override | |
public String getClientInfo(String name) throws SQLException { | |
return altConn.getClientInfo(name); | |
} | |
@Override | |
public Properties getClientInfo() throws SQLException { | |
return altConn.getClientInfo(); | |
} | |
@Override | |
public Array createArrayOf(String typeName, Object[] elements) throws SQLException { | |
return altConn.createArrayOf(typeName, elements); | |
} | |
@Override | |
public Struct createStruct(String typeName, Object[] attributes) throws SQLException { | |
return altConn.createStruct(typeName, attributes); | |
} | |
@Override | |
public void setSchema(String schema) throws SQLException { | |
altConn.setSchema(schema); | |
} | |
@Override | |
public String getSchema() throws SQLException { | |
return altConn.getSchema(); | |
} | |
@Override | |
public void abort(Executor executor) throws SQLException { | |
altConn.abort(executor); | |
} | |
@Override | |
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { | |
altConn.setNetworkTimeout(executor, milliseconds); | |
} | |
@Override | |
public int getNetworkTimeout() throws SQLException { | |
return altConn.getNetworkTimeout(); | |
} | |
@Override | |
public <T> T unwrap(Class<T> iface) throws SQLException { | |
return altConn.unwrap(iface); | |
} | |
@Override | |
public boolean isWrapperFor(Class<?> iface) throws SQLException { | |
return altConn.isWrapperFor(iface); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.alternate; | |
import oracle.jdbc.driver.OracleDriver; | |
import java.sql.*; | |
import java.util.Properties; | |
import java.util.logging.Logger; | |
import static java.lang.Class.forName; | |
public class ODriver implements Driver { | |
private OracleDriver oracleDriver; | |
static { | |
try { | |
DriverManager.registerDriver(new ODriver()); | |
} catch (SQLException e) { | |
throw new RuntimeException(e); | |
} | |
} | |
@Override | |
public Connection connect(String url, Properties info) throws SQLException { | |
System.out.println("connect() url=" + url); | |
try { | |
forName("oracle.jdbc.driver.OracleDriver"); | |
} catch (ClassNotFoundException e) { | |
throw new RuntimeException(e); | |
} | |
oracleDriver = new OracleDriver(); | |
Connection connect = oracleDriver.connect("jdbc:oracle:thin:" + url, info); | |
return new OConnection(connect); | |
} | |
@Override | |
public boolean acceptsURL(String url) throws SQLException { | |
return oracleDriver.acceptsURL(url); | |
} | |
@Override | |
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { | |
return oracleDriver.getPropertyInfo(url, info); | |
} | |
@Override | |
public int getMajorVersion() { | |
return oracleDriver.getMajorVersion(); | |
} | |
@Override | |
public int getMinorVersion() { | |
return oracleDriver.getMinorVersion(); | |
} | |
@Override | |
public boolean jdbcCompliant() { | |
return oracleDriver.jdbcCompliant(); | |
} | |
@Override | |
public Logger getParentLogger() throws SQLFeatureNotSupportedException { | |
return Logger.getLogger("root"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.alternate; | |
import java.io.InputStream; | |
import java.io.Reader; | |
import java.math.BigDecimal; | |
import java.net.URL; | |
import java.sql.*; | |
import java.util.Calendar; | |
public class OPreparedStatement implements PreparedStatement { | |
private PreparedStatement altStatement; | |
public OPreparedStatement(PreparedStatement preparedStatement) { | |
altStatement = preparedStatement; | |
} | |
@Override | |
public ResultSet executeQuery() throws SQLException { | |
return altStatement.executeQuery(); | |
} | |
@Override | |
public int executeUpdate() throws SQLException { | |
return altStatement.executeUpdate(); | |
} | |
@Override | |
public void setNull(int parameterIndex, int sqlType) throws SQLException { | |
altStatement.setNull(parameterIndex, sqlType); | |
} | |
@Override | |
public void setBoolean(int parameterIndex, boolean x) throws SQLException { | |
altStatement.setBoolean(parameterIndex, x); | |
} | |
@Override | |
public void setByte(int parameterIndex, byte x) throws SQLException { | |
altStatement.setByte(parameterIndex, x); | |
} | |
@Override | |
public void setShort(int parameterIndex, short x) throws SQLException { | |
altStatement.setShort(parameterIndex, x); | |
} | |
@Override | |
public void setInt(int parameterIndex, int x) throws SQLException { | |
altStatement.setInt(parameterIndex, x); | |
} | |
@Override | |
public void setLong(int parameterIndex, long x) throws SQLException { | |
altStatement.setLong(parameterIndex, x); | |
} | |
@Override | |
public void setFloat(int parameterIndex, float x) throws SQLException { | |
altStatement.setFloat(parameterIndex, x); | |
} | |
@Override | |
public void setDouble(int parameterIndex, double x) throws SQLException { | |
altStatement.setDouble(parameterIndex, x); | |
} | |
@Override | |
public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { | |
altStatement.setBigDecimal(parameterIndex, x); | |
} | |
@Override | |
public void setString(int parameterIndex, String x) throws SQLException { | |
altStatement.setString(parameterIndex, x); | |
} | |
@Override | |
public void setBytes(int parameterIndex, byte[] x) throws SQLException { | |
altStatement.setBytes(parameterIndex, x); | |
} | |
@Override | |
public void setDate(int parameterIndex, Date x) throws SQLException { | |
altStatement.setDate(parameterIndex, x); | |
} | |
@Override | |
public void setTime(int parameterIndex, Time x) throws SQLException { | |
altStatement.setTime(parameterIndex, x); | |
} | |
@Override | |
public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { | |
altStatement.setTimestamp(parameterIndex, x); | |
} | |
@Override | |
public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException { | |
altStatement.setAsciiStream(parameterIndex, x, length); | |
} | |
@Override | |
public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException { | |
altStatement.setUnicodeStream(parameterIndex, x, length); | |
} | |
@Override | |
public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { | |
altStatement.setBinaryStream(parameterIndex, x, length); | |
} | |
@Override | |
public void clearParameters() throws SQLException { | |
altStatement.clearParameters(); | |
} | |
@Override | |
public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException { | |
altStatement.setObject(parameterIndex, x, targetSqlType); | |
} | |
@Override | |
public void setObject(int parameterIndex, Object x) throws SQLException { | |
altStatement.setObject(parameterIndex, x); | |
} | |
@Override | |
public boolean execute() throws SQLException { | |
return altStatement.execute(); | |
} | |
@Override | |
public void addBatch() throws SQLException { | |
altStatement.addBatch(); | |
} | |
@Override | |
public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException { | |
altStatement.setCharacterStream(parameterIndex, reader, length); | |
} | |
@Override | |
public void setRef(int parameterIndex, Ref x) throws SQLException { | |
altStatement.setRef(parameterIndex, x); | |
} | |
@Override | |
public void setBlob(int parameterIndex, Blob x) throws SQLException { | |
altStatement.setBlob(parameterIndex, x); | |
} | |
@Override | |
public void setClob(int parameterIndex, Clob x) throws SQLException { | |
altStatement.setClob(parameterIndex, x); | |
} | |
@Override | |
public void setArray(int parameterIndex, Array x) throws SQLException { | |
altStatement.setArray(parameterIndex, x); | |
} | |
@Override | |
public ResultSetMetaData getMetaData() throws SQLException { | |
return altStatement.getMetaData(); | |
} | |
@Override | |
public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException { | |
altStatement.setDate(parameterIndex, x, cal); | |
} | |
@Override | |
public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { | |
altStatement.setTime(parameterIndex, x, cal); | |
} | |
@Override | |
public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException { | |
altStatement.setTimestamp(parameterIndex, x, cal); | |
} | |
@Override | |
public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException { | |
altStatement.setNull(parameterIndex, sqlType, typeName); | |
} | |
@Override | |
public void setURL(int parameterIndex, URL x) throws SQLException { | |
altStatement.setURL(parameterIndex, x); | |
} | |
@Override | |
public ParameterMetaData getParameterMetaData() throws SQLException { | |
return altStatement.getParameterMetaData(); | |
} | |
@Override | |
public void setRowId(int parameterIndex, RowId x) throws SQLException { | |
altStatement.setRowId(parameterIndex, x); | |
} | |
@Override | |
public void setNString(int parameterIndex, String value) throws SQLException { | |
altStatement.setNString(parameterIndex, value); | |
} | |
@Override | |
public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException { | |
altStatement.setNCharacterStream(parameterIndex, value, length); | |
} | |
@Override | |
public void setNClob(int parameterIndex, NClob value) throws SQLException { | |
altStatement.setNClob(parameterIndex, value); | |
} | |
@Override | |
public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { | |
altStatement.setClob(parameterIndex, reader, length); | |
} | |
@Override | |
public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException { | |
altStatement.setBlob(parameterIndex, inputStream, length); | |
} | |
@Override | |
public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { | |
altStatement.setNClob(parameterIndex, reader, length); | |
} | |
@Override | |
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { | |
altStatement.setSQLXML(parameterIndex, xmlObject); | |
} | |
@Override | |
public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException { | |
altStatement.setObject(parameterIndex, x, targetSqlType, scaleOrLength); | |
} | |
@Override | |
public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException { | |
altStatement.setAsciiStream(parameterIndex, x, length); | |
} | |
@Override | |
public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException { | |
altStatement.setBinaryStream(parameterIndex, x, length); | |
} | |
@Override | |
public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException { | |
altStatement.setCharacterStream(parameterIndex, reader, length); | |
} | |
@Override | |
public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { | |
altStatement.setAsciiStream(parameterIndex, x); | |
} | |
@Override | |
public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { | |
altStatement.setBinaryStream(parameterIndex, x); | |
} | |
@Override | |
public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { | |
altStatement.setCharacterStream(parameterIndex, reader); | |
} | |
@Override | |
public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { | |
altStatement.setNCharacterStream(parameterIndex, value); | |
} | |
@Override | |
public void setClob(int parameterIndex, Reader reader) throws SQLException { | |
altStatement.setClob(parameterIndex, reader); | |
} | |
@Override | |
public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { | |
altStatement.setBlob(parameterIndex, inputStream); | |
} | |
@Override | |
public void setNClob(int parameterIndex, Reader reader) throws SQLException { | |
altStatement.setClob(parameterIndex, reader); | |
} | |
@Override | |
public ResultSet executeQuery(String sql) throws SQLException { | |
return altStatement.executeQuery(sql); | |
} | |
@Override | |
public int executeUpdate(String sql) throws SQLException { | |
return altStatement.executeUpdate(sql); | |
} | |
@Override | |
public void close() throws SQLException { | |
altStatement.close(); | |
} | |
@Override | |
public int getMaxFieldSize() throws SQLException { | |
return altStatement.getMaxFieldSize(); | |
} | |
@Override | |
public void setMaxFieldSize(int max) throws SQLException { | |
altStatement.setMaxFieldSize(max); | |
} | |
@Override | |
public int getMaxRows() throws SQLException { | |
return altStatement.getMaxRows(); | |
} | |
@Override | |
public void setMaxRows(int max) throws SQLException { | |
altStatement.setMaxRows(max); | |
} | |
@Override | |
public void setEscapeProcessing(boolean enable) throws SQLException { | |
altStatement.setEscapeProcessing(enable); | |
} | |
@Override | |
public int getQueryTimeout() throws SQLException { | |
return altStatement.getQueryTimeout(); | |
} | |
@Override | |
public void setQueryTimeout(int seconds) throws SQLException { | |
altStatement.setQueryTimeout(seconds); | |
} | |
@Override | |
public void cancel() throws SQLException { | |
altStatement.cancel(); | |
} | |
@Override | |
public SQLWarning getWarnings() throws SQLException { | |
return altStatement.getWarnings(); | |
} | |
@Override | |
public void clearWarnings() throws SQLException { | |
altStatement.clearWarnings(); | |
} | |
@Override | |
public void setCursorName(String name) throws SQLException { | |
altStatement.setCursorName(name); | |
} | |
@Override | |
public boolean execute(String sql) throws SQLException { | |
return altStatement.execute(sql); | |
} | |
@Override | |
public ResultSet getResultSet() throws SQLException { | |
return altStatement.getResultSet(); | |
} | |
@Override | |
public int getUpdateCount() throws SQLException { | |
return altStatement.getUpdateCount(); | |
} | |
@Override | |
public boolean getMoreResults() throws SQLException { | |
return altStatement.getMoreResults(); | |
} | |
@Override | |
public void setFetchDirection(int direction) throws SQLException { | |
altStatement.setFetchDirection(direction); | |
} | |
@Override | |
public int getFetchDirection() throws SQLException { | |
return altStatement.getFetchDirection(); | |
} | |
@Override | |
public void setFetchSize(int rows) throws SQLException { | |
altStatement.setFetchSize(rows); | |
} | |
@Override | |
public int getFetchSize() throws SQLException { | |
return altStatement.getFetchSize(); | |
} | |
@Override | |
public int getResultSetConcurrency() throws SQLException { | |
return altStatement.getResultSetConcurrency(); | |
} | |
@Override | |
public int getResultSetType() throws SQLException { | |
return altStatement.getResultSetType(); | |
} | |
@Override | |
public void addBatch(String sql) throws SQLException { | |
altStatement.addBatch(sql); | |
} | |
@Override | |
public void clearBatch() throws SQLException { | |
altStatement.clearBatch(); | |
} | |
@Override | |
public int[] executeBatch() throws SQLException { | |
return altStatement.executeBatch(); | |
} | |
@Override | |
public Connection getConnection() throws SQLException { | |
return altStatement.getConnection(); | |
} | |
@Override | |
public boolean getMoreResults(int current) throws SQLException { | |
return altStatement.getMoreResults(current); | |
} | |
@Override | |
public ResultSet getGeneratedKeys() throws SQLException { | |
return altStatement.getGeneratedKeys(); | |
} | |
@Override | |
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { | |
return altStatement.executeUpdate(sql, autoGeneratedKeys); | |
} | |
@Override | |
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { | |
return altStatement.executeUpdate(sql, columnIndexes); | |
} | |
@Override | |
public int executeUpdate(String sql, String[] columnNames) throws SQLException { | |
return altStatement.executeUpdate(sql, columnNames); | |
} | |
@Override | |
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { | |
return altStatement.execute(sql, autoGeneratedKeys); | |
} | |
@Override | |
public boolean execute(String sql, int[] columnIndexes) throws SQLException { | |
return altStatement.execute(sql, columnIndexes); | |
} | |
@Override | |
public boolean execute(String sql, String[] columnNames) throws SQLException { | |
return altStatement.execute(sql, columnNames); | |
} | |
@Override | |
public int getResultSetHoldability() throws SQLException { | |
return altStatement.getResultSetHoldability(); | |
} | |
@Override | |
public boolean isClosed() throws SQLException { | |
return altStatement.isClosed(); | |
} | |
@Override | |
public void setPoolable(boolean poolable) throws SQLException { | |
altStatement.setPoolable(poolable); | |
} | |
@Override | |
public boolean isPoolable() throws SQLException { | |
return altStatement.isPoolable(); | |
} | |
@Override | |
public void closeOnCompletion() throws SQLException { | |
altStatement.closeOnCompletion(); | |
} | |
@Override | |
public boolean isCloseOnCompletion() throws SQLException { | |
return altStatement.isCloseOnCompletion(); | |
} | |
@Override | |
public <T> T unwrap(Class<T> iface) throws SQLException { | |
return altStatement.unwrap(iface); | |
} | |
@Override | |
public boolean isWrapperFor(Class<?> iface) throws SQLException { | |
return altStatement.isWrapperFor(iface); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.alternate; | |
import java.sql.*; | |
public class OStatement implements Statement { | |
private Statement altStatement; | |
public OStatement(Statement statement) { | |
altStatement = statement; | |
System.out.println("OStatement() + " + statement.getClass().getName()); | |
} | |
@Override | |
public ResultSet executeQuery(String sql) throws SQLException { | |
return altStatement.executeQuery(sql); | |
} | |
@Override | |
public int executeUpdate(String sql) throws SQLException { | |
return altStatement.executeUpdate(sql); | |
} | |
@Override | |
public void close() throws SQLException { | |
altStatement.close(); | |
} | |
@Override | |
public int getMaxFieldSize() throws SQLException { | |
return altStatement.getMaxFieldSize(); | |
} | |
@Override | |
public void setMaxFieldSize(int max) throws SQLException { | |
altStatement.setMaxFieldSize(max); | |
} | |
@Override | |
public int getMaxRows() throws SQLException { | |
return altStatement.getMaxRows(); | |
} | |
@Override | |
public void setMaxRows(int max) throws SQLException { | |
altStatement.setMaxRows(max); | |
} | |
@Override | |
public void setEscapeProcessing(boolean enable) throws SQLException { | |
altStatement.setEscapeProcessing(enable); | |
} | |
@Override | |
public int getQueryTimeout() throws SQLException { | |
return altStatement.getQueryTimeout(); | |
} | |
@Override | |
public void setQueryTimeout(int seconds) throws SQLException { | |
altStatement.setQueryTimeout(seconds); | |
} | |
@Override | |
public void cancel() throws SQLException { | |
altStatement.cancel(); | |
} | |
@Override | |
public SQLWarning getWarnings() throws SQLException { | |
return altStatement.getWarnings(); | |
} | |
@Override | |
public void clearWarnings() throws SQLException { | |
altStatement.clearWarnings(); | |
} | |
@Override | |
public void setCursorName(String name) throws SQLException { | |
altStatement.setCursorName(name); | |
} | |
@Override | |
public boolean execute(String sql) throws SQLException { | |
return altStatement.execute(sql); | |
} | |
@Override | |
public ResultSet getResultSet() throws SQLException { | |
return altStatement.getResultSet(); | |
} | |
@Override | |
public int getUpdateCount() throws SQLException { | |
return altStatement.getUpdateCount(); | |
} | |
@Override | |
public boolean getMoreResults() throws SQLException { | |
return altStatement.getMoreResults(); | |
} | |
@Override | |
public void setFetchDirection(int direction) throws SQLException { | |
altStatement.setFetchDirection(direction); | |
} | |
@Override | |
public int getFetchDirection() throws SQLException { | |
return altStatement.getFetchDirection(); | |
} | |
@Override | |
public void setFetchSize(int rows) throws SQLException { | |
altStatement.setFetchSize(rows); | |
} | |
@Override | |
public int getFetchSize() throws SQLException { | |
return altStatement.getFetchSize(); | |
} | |
@Override | |
public int getResultSetConcurrency() throws SQLException { | |
return altStatement.getResultSetConcurrency(); | |
} | |
@Override | |
public int getResultSetType() throws SQLException { | |
return altStatement.getResultSetType(); | |
} | |
@Override | |
public void addBatch(String sql) throws SQLException { | |
altStatement.addBatch(sql); | |
} | |
@Override | |
public void clearBatch() throws SQLException { | |
altStatement.clearBatch(); | |
} | |
@Override | |
public int[] executeBatch() throws SQLException { | |
return altStatement.executeBatch(); | |
} | |
@Override | |
public Connection getConnection() throws SQLException { | |
return altStatement.getConnection(); | |
} | |
@Override | |
public boolean getMoreResults(int current) throws SQLException { | |
return altStatement.getMoreResults(current); | |
} | |
@Override | |
public ResultSet getGeneratedKeys() throws SQLException { | |
return altStatement.getGeneratedKeys(); | |
} | |
@Override | |
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { | |
return altStatement.executeUpdate(sql, autoGeneratedKeys); | |
} | |
@Override | |
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { | |
return altStatement.executeUpdate(sql, columnIndexes); | |
} | |
@Override | |
public int executeUpdate(String sql, String[] columnNames) throws SQLException { | |
return altStatement.executeUpdate(sql, columnNames); | |
} | |
@Override | |
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { | |
return altStatement.execute(sql, autoGeneratedKeys); | |
} | |
@Override | |
public boolean execute(String sql, int[] columnIndexes) throws SQLException { | |
return altStatement.execute(sql, columnIndexes); | |
} | |
@Override | |
public boolean execute(String sql, String[] columnNames) throws SQLException { | |
return altStatement.execute(sql, columnNames); | |
} | |
@Override | |
public int getResultSetHoldability() throws SQLException { | |
return altStatement.getResultSetHoldability(); | |
} | |
@Override | |
public boolean isClosed() throws SQLException { | |
return altStatement.isClosed(); | |
} | |
@Override | |
public void setPoolable(boolean poolable) throws SQLException { | |
altStatement.setPoolable(poolable); | |
} | |
@Override | |
public boolean isPoolable() throws SQLException { | |
return altStatement.isPoolable(); | |
} | |
@Override | |
public void closeOnCompletion() throws SQLException { | |
altStatement.closeOnCompletion(); | |
} | |
@Override | |
public boolean isCloseOnCompletion() throws SQLException { | |
return altStatement.isCloseOnCompletion(); | |
} | |
@Override | |
public <T> T unwrap(Class<T> iface) throws SQLException { | |
return altStatement.unwrap(iface); | |
} | |
@Override | |
public boolean isWrapperFor(Class<?> iface) throws SQLException { | |
return altStatement.isWrapperFor(iface); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Test; | |
import java.sql.*; | |
import static java.lang.Class.forName; | |
public class TestOracle { | |
@Test | |
public void test1() throws ClassNotFoundException, SQLException { | |
// forName("oracle.jdbc.driver.OracleDriver"); | |
forName("com.example.alternate.ODriver"); | |
System.out.println("com.example.alternate.ODriver()"); | |
try(Connection conn = DriverManager.getConnection("@localhost:orcl","user","pass")) { | |
System.out.println(conn.getClass().getName()); | |
Statement statement = conn.createStatement(); | |
System.out.println(statement.getClass().getName()); | |
ResultSet resultSet = statement.executeQuery("select * from member"); | |
System.out.println(resultSet.getClass().getName()); | |
while(resultSet.next()) { | |
System.out.println(resultSet.getString("ID")); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment