/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.eas.client.resourcepool;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.*;
import java.util.Calendar;
/**
*
* @author mg
*/
public class BearPreparedStatement implements PreparedStatement{
protected String sqlClause;
protected PreparedStatement delegate;
protected BearDatabaseConnection owningConnection;
public BearPreparedStatement(String aSqlClause, PreparedStatement aDelegate, BearDatabaseConnection aOwningConnection) {
super();
sqlClause = aSqlClause;
delegate = aDelegate;
owningConnection = aOwningConnection;
}
@Override
public boolean isCloseOnCompletion() throws SQLException {
return false;
}
@Override
public void closeOnCompletion() throws SQLException {
}
public String getSqlClause() {
return sqlClause;
}
@Override
public ResultSet executeQuery() throws SQLException {
checkClosed();
return delegate.executeQuery();
}
@Override
public int executeUpdate() throws SQLException {
checkClosed();
return delegate.executeUpdate();
}
@Override
public void setNull(int parameterIndex, int sqlType) throws SQLException {
checkClosed();
delegate.setNull(parameterIndex, sqlType);
}
@Override
public void setBoolean(int parameterIndex, boolean x) throws SQLException {
checkClosed();
delegate.setBoolean(parameterIndex, x);
}
@Override
public void setByte(int parameterIndex, byte x) throws SQLException {
checkClosed();
delegate.setByte(parameterIndex, x);
}
@Override
public void setShort(int parameterIndex, short x) throws SQLException {
checkClosed();
delegate.setShort(parameterIndex, x);
}
@Override
public void setInt(int parameterIndex, int x) throws SQLException {
checkClosed();
delegate.setInt(parameterIndex, x);
}
@Override
public void setLong(int parameterIndex, long x) throws SQLException {
checkClosed();
delegate.setLong(parameterIndex, x);
}
@Override
public void setFloat(int parameterIndex, float x) throws SQLException {
checkClosed();
delegate.setFloat(parameterIndex, x);
}
@Override
public void setDouble(int parameterIndex, double x) throws SQLException {
checkClosed();
delegate.setDouble(parameterIndex, x);
}
@Override
public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException {
checkClosed();
delegate.setBigDecimal(parameterIndex, x);
}
@Override
public void setString(int parameterIndex, String x) throws SQLException {
checkClosed();
delegate.setString(parameterIndex, x);
}
@Override
public void setBytes(int parameterIndex, byte[] x) throws SQLException {
checkClosed();
delegate.setBytes(parameterIndex, x);
}
@Override
public void setDate(int parameterIndex, Date x) throws SQLException {
checkClosed();
delegate.setDate(parameterIndex, x);
}
@Override
public void setTime(int parameterIndex, Time x) throws SQLException {
checkClosed();
delegate.setTime(parameterIndex, x);
}
@Override
public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException {
checkClosed();
delegate.setTimestamp(parameterIndex, x);
}
@Override
public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException {
checkClosed();
delegate.setAsciiStream(parameterIndex, x, length);
}
/**
* {@inheritDoc}
* @deprecated
*/
@Override
public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException {
checkClosed();
delegate.setUnicodeStream(parameterIndex, x, length);
}
@Override
public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException {
checkClosed();
delegate.setBinaryStream(parameterIndex, x, length);
}
@Override
public void clearParameters() throws SQLException {
checkClosed();
delegate.clearParameters();
}
@Override
public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException {
checkClosed();
delegate.setObject(parameterIndex, x, targetSqlType);
}
@Override
public void setObject(int parameterIndex, Object x) throws SQLException {
checkClosed();
delegate.setObject(parameterIndex, x);
}
@Override
public boolean execute() throws SQLException {
checkClosed();
return delegate.execute();
}
@Override
public void addBatch() throws SQLException {
checkClosed();
delegate.addBatch();
}
@Override
public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException {
checkClosed();
delegate.setCharacterStream(parameterIndex, reader, length);
}
@Override
public void setRef(int parameterIndex, Ref x) throws SQLException {
checkClosed();
delegate.setRef(parameterIndex, x);
}
@Override
public void setBlob(int parameterIndex, Blob x) throws SQLException {
checkClosed();
delegate.setBlob(parameterIndex, x);
}
@Override
public void setClob(int parameterIndex, Clob x) throws SQLException {
checkClosed();
delegate.setClob(parameterIndex, x);
}
@Override
public void setArray(int parameterIndex, Array x) throws SQLException {
checkClosed();
delegate.setArray(parameterIndex, x);
}
@Override
public ResultSetMetaData getMetaData() throws SQLException {
checkClosed();
return delegate.getMetaData();
}
@Override
public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException {
checkClosed();
delegate.setDate(parameterIndex, x, cal);
}
@Override
public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
checkClosed();
delegate.setTime(parameterIndex, x, cal);
}
@Override
public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException {
checkClosed();
delegate.setTimestamp(parameterIndex, x, cal);
}
@Override
public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException {
checkClosed();
delegate.setNull(parameterIndex, sqlType, typeName);
}
@Override
public void setURL(int parameterIndex, URL x) throws SQLException {
checkClosed();
delegate.setURL(parameterIndex, x);
}
@Override
public ParameterMetaData getParameterMetaData() throws SQLException {
checkClosed();
return delegate.getParameterMetaData();
}
@Override
public void setRowId(int parameterIndex, RowId x) throws SQLException {
checkClosed();
delegate.setRowId(parameterIndex, x);
}
@Override
public void setNString(int parameterIndex, String value) throws SQLException {
checkClosed();
delegate.setNString(parameterIndex, value);
}
@Override
public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException {
checkClosed();
delegate.setNCharacterStream(parameterIndex, value, length);
}
@Override
public void setNClob(int parameterIndex, NClob value) throws SQLException {
checkClosed();
delegate.setNClob(parameterIndex, value);
}
@Override
public void setClob(int parameterIndex, Reader reader, long length) throws SQLException {
checkClosed();
delegate.setClob(parameterIndex, reader, length);
}
@Override
public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException {
checkClosed();
delegate.setBlob(parameterIndex, inputStream, length);
}
@Override
public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException {
checkClosed();
delegate.setNClob(parameterIndex, reader, length);
}
@Override
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException {
checkClosed();
delegate.setSQLXML(parameterIndex, xmlObject);
}
@Override
public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException {
checkClosed();
delegate.setObject(parameterIndex, x, targetSqlType, scaleOrLength);
}
@Override
public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException {
checkClosed();
delegate.setAsciiStream(parameterIndex, x, length);
}
@Override
public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException {
checkClosed();
delegate.setBinaryStream(parameterIndex, x, length);
}
@Override
public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException {
checkClosed();
delegate.setCharacterStream(parameterIndex, reader, length);
}
@Override
public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException {
checkClosed();
delegate.setAsciiStream(parameterIndex, x);
}
@Override
public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException {
checkClosed();
delegate.setBinaryStream(parameterIndex, x);
}
@Override
public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException {
checkClosed();
delegate.setCharacterStream(parameterIndex, reader);
}
@Override
public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException {
checkClosed();
delegate.setNCharacterStream(parameterIndex, value);
}
@Override
public void setClob(int parameterIndex, Reader reader) throws SQLException {
checkClosed();
delegate.setClob(parameterIndex, reader);
}
@Override
public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException {
checkClosed();
delegate.setBlob(parameterIndex, inputStream);
}
@Override
public void setNClob(int parameterIndex, Reader reader) throws SQLException {
checkClosed();
delegate.setNClob(parameterIndex, reader);
}
@Override
public ResultSet executeQuery(String sql) throws SQLException {
checkClosed();
return delegate.executeQuery(sql);
}
@Override
public int executeUpdate(String sql) throws SQLException {
checkClosed();
return delegate.executeUpdate(sql);
}
@Override
public void close() throws SQLException {
checkClosed();
owningConnection.returnPreparedStatement(sqlClause, delegate);
delegate = null;
}
@Override
public int getMaxFieldSize() throws SQLException {
checkClosed();
return delegate.getMaxFieldSize();
}
@Override
public void setMaxFieldSize(int max) throws SQLException {
checkClosed();
delegate.setMaxFieldSize(max);
}
@Override
public int getMaxRows() throws SQLException {
checkClosed();
return delegate.getMaxRows();
}
@Override
public void setMaxRows(int max) throws SQLException {
checkClosed();
delegate.setMaxRows(max);
}
@Override
public void setEscapeProcessing(boolean enable) throws SQLException {
checkClosed();
delegate.setEscapeProcessing(enable);
}
@Override
public int getQueryTimeout() throws SQLException {
checkClosed();
return delegate.getQueryTimeout();
}
@Override
public void setQueryTimeout(int seconds) throws SQLException {
checkClosed();
delegate.setQueryTimeout(seconds);
}
@Override
public void cancel() throws SQLException {
checkClosed();
delegate.cancel();
}
@Override
public SQLWarning getWarnings() throws SQLException {
checkClosed();
return delegate.getWarnings();
}
@Override
public void clearWarnings() throws SQLException {
checkClosed();
delegate.clearWarnings();
}
@Override
public void setCursorName(String name) throws SQLException {
checkClosed();
delegate.setCursorName(name);
}
@Override
public boolean execute(String sql) throws SQLException {
checkClosed();
return delegate.execute(sql);
}
@Override
public ResultSet getResultSet() throws SQLException {
checkClosed();
return delegate.getResultSet();
}
@Override
public int getUpdateCount() throws SQLException {
checkClosed();
return delegate.getUpdateCount();
}
@Override
public boolean getMoreResults() throws SQLException {
checkClosed();
return delegate.getMoreResults();
}
@Override
public void setFetchDirection(int direction) throws SQLException {
checkClosed();
delegate.setFetchDirection(direction);
}
@Override
public int getFetchDirection() throws SQLException {
checkClosed();
return delegate.getFetchDirection();
}
@Override
public void setFetchSize(int rows) throws SQLException {
checkClosed();
delegate.setFetchSize(rows);
}
@Override
public int getFetchSize() throws SQLException {
checkClosed();
return delegate.getFetchSize();
}
@Override
public int getResultSetConcurrency() throws SQLException {
checkClosed();
return delegate.getResultSetConcurrency();
}
@Override
public int getResultSetType() throws SQLException {
checkClosed();
return delegate.getResultSetType();
}
@Override
public void addBatch(String sql) throws SQLException {
checkClosed();
delegate.addBatch(sql);
}
@Override
public void clearBatch() throws SQLException {
checkClosed();
delegate.clearBatch();
}
@Override
public int[] executeBatch() throws SQLException {
checkClosed();
return delegate.executeBatch();
}
@Override
public Connection getConnection() throws SQLException {
checkClosed();
return owningConnection;
}
@Override
public boolean getMoreResults(int current) throws SQLException {
checkClosed();
return delegate.getMoreResults(current);
}
@Override
public ResultSet getGeneratedKeys() throws SQLException {
checkClosed();
return delegate.getGeneratedKeys();
}
@Override
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
checkClosed();
return delegate.executeUpdate(sql, autoGeneratedKeys);
}
@Override
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
checkClosed();
return delegate.executeUpdate(sql, columnIndexes);
}
@Override
public int executeUpdate(String sql, String[] columnNames) throws SQLException {
checkClosed();
return delegate.executeUpdate(sql, columnNames);
}
@Override
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
checkClosed();
return delegate.execute(sql, autoGeneratedKeys);
}
@Override
public boolean execute(String sql, int[] columnIndexes) throws SQLException {
checkClosed();
return delegate.execute(sql, columnIndexes);
}
@Override
public boolean execute(String sql, String[] columnNames) throws SQLException {
checkClosed();
return delegate.execute(sql, columnNames);
}
@Override
public int getResultSetHoldability() throws SQLException {
checkClosed();
return delegate.getResultSetHoldability();
}
@Override
public boolean isClosed() throws SQLException {
return delegate == null || delegate.isClosed();
}
@Override
public void setPoolable(boolean poolable) throws SQLException {
}
@Override
public boolean isPoolable() throws SQLException {
return true;
}
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
checkClosed();
if (isWrapperFor(iface)) {
return (T) delegate;
} else {
return null;
}
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
checkClosed();
return delegate.getClass().isAssignableFrom(iface);
}
protected void checkClosed() throws SQLException {
if (delegate == null) {
throw new SQLException("Statement already closed.");
}
}
}