|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.boylesoftware.cb2.util.sql.StatementWrapper com.boylesoftware.cb2.util.sql.PreparedStatementWrapper
Wrapper around a JDBC's PreparedStatement
interface
implementation. You can derive your statement wrapper classes from
this one and override some of its methods, while all the others
will be calling appropriate methods on the wrapped, "real" statement.
This class also provides some "hook" methods called in certain situations. Note that if your redefine interface methods in your subclass and you use hooks you will have to call the base method from your redefined one in order to make the hooks invoked. Alternatively you call them yourself directly from the redefined interface method.
Field Summary | |
protected java.sql.PreparedStatement |
pstmt
Reference to the wrapped statement as a prepared statement so we don't have to do class casting all the time. |
Fields inherited from class com.boylesoftware.cb2.util.sql.StatementWrapper |
con, EXECUTE_TYPE_BATCH, EXECUTE_TYPE_GENERIC, EXECUTE_TYPE_QUERY, EXECUTE_TYPE_UPDATE, stmt |
Fields inherited from interface java.sql.Statement |
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO |
Constructor Summary | |
PreparedStatementWrapper()
Creates a new wrapper. |
|
PreparedStatementWrapper(java.sql.PreparedStatement pstmt)
Creates a new wrapper and sets the wrapped statement to the specified one. |
Method Summary | |
void |
addBatch()
Interface method wrapper. |
void |
clearParameters()
Interface method wrapper. |
boolean |
execute()
Interface method wrapper. |
java.sql.ResultSet |
executeQuery()
Interface method wrapper. |
int |
executeUpdate()
Interface method wrapper. |
java.sql.ResultSetMetaData |
getMetaData()
Interface method wrapper. |
java.sql.ParameterMetaData |
getParameterMetaData()
Interface method wrapper. |
java.sql.PreparedStatement |
getWrappedPreparedStatement()
Returns the wrapped prepared statement. |
void |
setArray(int i,
java.sql.Array x)
Interface method wrapper. |
void |
setAsciiStream(int parameterIndex,
java.io.InputStream x,
int length)
Interface method wrapper. |
void |
setBigDecimal(int parameterIndex,
java.math.BigDecimal x)
Interface method wrapper. |
void |
setBinaryStream(int parameterIndex,
java.io.InputStream x,
int length)
Interface method wrapper. |
void |
setBlob(int i,
java.sql.Blob x)
Interface method wrapper. |
void |
setBoolean(int parameterIndex,
boolean x)
Interface method wrapper. |
void |
setByte(int parameterIndex,
byte x)
Interface method wrapper. |
void |
setBytes(int parameterIndex,
byte[] x)
Interface method wrapper. |
void |
setCharacterStream(int parameterIndex,
java.io.Reader reader,
int length)
Interface method wrapper. |
void |
setClob(int i,
java.sql.Clob x)
Interface method wrapper. |
void |
setDate(int parameterIndex,
java.sql.Date x)
Interface method wrapper. |
void |
setDate(int parameterIndex,
java.sql.Date x,
java.util.Calendar cal)
Interface method wrapper. |
void |
setDouble(int parameterIndex,
double x)
Interface method wrapper. |
void |
setFloat(int parameterIndex,
float x)
Interface method wrapper. |
void |
setInt(int parameterIndex,
int x)
Interface method wrapper. |
void |
setLong(int parameterIndex,
long x)
Interface method wrapper. |
void |
setNull(int parameterIndex,
int sqlType)
Interface method wrapper. |
void |
setNull(int paramIndex,
int sqlType,
java.lang.String typeName)
Interface method wrapper. |
void |
setObject(int parameterIndex,
java.lang.Object x)
Interface method wrapper. |
void |
setObject(int parameterIndex,
java.lang.Object x,
int targetSqlType)
Interface method wrapper. |
void |
setObject(int parameterIndex,
java.lang.Object x,
int targetSqlType,
int scale)
Interface method wrapper. |
protected java.lang.Object |
setParameterHook(int index,
java.lang.Object param)
This hook is called by all methods that set query parameters. |
void |
setRef(int i,
java.sql.Ref x)
Interface method wrapper. |
void |
setShort(int parameterIndex,
short x)
Interface method wrapper. |
void |
setString(int parameterIndex,
java.lang.String x)
Interface method wrapper. |
void |
setTime(int parameterIndex,
java.sql.Time x)
Interface method wrapper. |
void |
setTime(int parameterIndex,
java.sql.Time x,
java.util.Calendar cal)
Interface method wrapper. |
void |
setTimestamp(int parameterIndex,
java.sql.Timestamp x)
Interface method wrapper. |
void |
setTimestamp(int parameterIndex,
java.sql.Timestamp x,
java.util.Calendar cal)
Interface method wrapper. |
void |
setUnicodeStream(int parameterIndex,
java.io.InputStream x,
int length)
Deprecated. |
void |
setURL(int parameterIndex,
java.net.URL x)
Interface method wrapper. |
void |
setWrappedStatement(java.sql.Statement stmt)
Sets the wrapped statement. |
Methods inherited from class com.boylesoftware.cb2.util.sql.StatementWrapper |
addBatch, cancel, clearBatch, clearWarnings, close, execute, execute, execute, execute, executeBatch, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, getWrappedStatement, postCallHook, postexecuteHook, preexecuteHook, setConnection, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setQueryTimeout |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.sql.Statement |
addBatch, cancel, clearBatch, clearWarnings, close, execute, execute, execute, execute, executeBatch, executeQuery, executeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setQueryTimeout |
Field Detail |
protected java.sql.PreparedStatement pstmt
Constructor Detail |
public PreparedStatementWrapper()
setWrappedStatement
call before using the
instance.
public PreparedStatementWrapper(java.sql.PreparedStatement pstmt)
pstmt
- the prepared statement to be wrapped.Method Detail |
public void setWrappedStatement(java.sql.Statement stmt)
setWrappedStatement
in class StatementWrapper
stmt
- statement to wrap, must be a prepared statement.
java.lang.IllegalArgumentException
- if the specified argument is not
a prepared statement.public java.sql.PreparedStatement getWrappedPreparedStatement()
public java.sql.ResultSet executeQuery() throws java.sql.SQLException
Also calles preexecuteHook
and
postexecuteHook
hooks.
executeQuery
in interface java.sql.PreparedStatement
java.sql.SQLException
public int executeUpdate() throws java.sql.SQLException
Also calles preexecuteHook
and
postexecuteHook
hooks.
executeUpdate
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setNull(int parameterIndex, int sqlType) throws java.sql.SQLException
setNull
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setBoolean(int parameterIndex, boolean x) throws java.sql.SQLException
setBoolean
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setByte(int parameterIndex, byte x) throws java.sql.SQLException
setByte
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setShort(int parameterIndex, short x) throws java.sql.SQLException
setShort
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setInt(int parameterIndex, int x) throws java.sql.SQLException
setInt
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setLong(int parameterIndex, long x) throws java.sql.SQLException
setLong
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setFloat(int parameterIndex, float x) throws java.sql.SQLException
setFloat
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setDouble(int parameterIndex, double x) throws java.sql.SQLException
setDouble
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setBigDecimal(int parameterIndex, java.math.BigDecimal x) throws java.sql.SQLException
setBigDecimal
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setString(int parameterIndex, java.lang.String x) throws java.sql.SQLException
setString
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setBytes(int parameterIndex, byte[] x) throws java.sql.SQLException
setBytes
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setDate(int parameterIndex, java.sql.Date x) throws java.sql.SQLException
setDate
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setTime(int parameterIndex, java.sql.Time x) throws java.sql.SQLException
setTime
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setTimestamp(int parameterIndex, java.sql.Timestamp x) throws java.sql.SQLException
setTimestamp
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setAsciiStream(int parameterIndex, java.io.InputStream x, int length) throws java.sql.SQLException
setAsciiStream
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setUnicodeStream(int parameterIndex, java.io.InputStream x, int length) throws java.sql.SQLException
setUnicodeStream
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setBinaryStream(int parameterIndex, java.io.InputStream x, int length) throws java.sql.SQLException
setBinaryStream
in interface java.sql.PreparedStatement
java.sql.SQLException
public void clearParameters() throws java.sql.SQLException
clearParameters
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setObject(int parameterIndex, java.lang.Object x, int targetSqlType, int scale) throws java.sql.SQLException
setObject
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setObject(int parameterIndex, java.lang.Object x, int targetSqlType) throws java.sql.SQLException
setObject
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setObject(int parameterIndex, java.lang.Object x) throws java.sql.SQLException
setObject
in interface java.sql.PreparedStatement
java.sql.SQLException
public boolean execute() throws java.sql.SQLException
Also calles preexecuteHook
and
postexecuteHook
hooks.
execute
in interface java.sql.PreparedStatement
java.sql.SQLException
public void addBatch() throws java.sql.SQLException
addBatch
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setCharacterStream(int parameterIndex, java.io.Reader reader, int length) throws java.sql.SQLException
setCharacterStream
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setRef(int i, java.sql.Ref x) throws java.sql.SQLException
setRef
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setBlob(int i, java.sql.Blob x) throws java.sql.SQLException
setBlob
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setClob(int i, java.sql.Clob x) throws java.sql.SQLException
setClob
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setArray(int i, java.sql.Array x) throws java.sql.SQLException
setArray
in interface java.sql.PreparedStatement
java.sql.SQLException
public java.sql.ResultSetMetaData getMetaData() throws java.sql.SQLException
getMetaData
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setDate(int parameterIndex, java.sql.Date x, java.util.Calendar cal) throws java.sql.SQLException
setDate
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setTime(int parameterIndex, java.sql.Time x, java.util.Calendar cal) throws java.sql.SQLException
setTime
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setTimestamp(int parameterIndex, java.sql.Timestamp x, java.util.Calendar cal) throws java.sql.SQLException
setTimestamp
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setNull(int paramIndex, int sqlType, java.lang.String typeName) throws java.sql.SQLException
setNull
in interface java.sql.PreparedStatement
java.sql.SQLException
public void setURL(int parameterIndex, java.net.URL x) throws java.sql.SQLException
setURL
in interface java.sql.PreparedStatement
java.sql.SQLException
public java.sql.ParameterMetaData getParameterMetaData() throws java.sql.SQLException
getParameterMetaData
in interface java.sql.PreparedStatement
java.sql.SQLException
protected java.lang.Object setParameterHook(int index, java.lang.Object param) throws java.sql.SQLException
param
.
index
- index of the parameter.param
- the param's value, which is properly wrapped if it is
a primitive type, null
if setNull
is called.
java.sql.SQLException
- if an error happens.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |