public class PreparedStatementWrapper extends StatementWrapper implements BackendPreparedStatement
Db.getPreparedStatement(org.tentackle.persist.StatementKey, boolean, int, int, java.util.function.Supplier<java.lang.String>).cancelled, con, openResultSet, ready, running, sql, stmt| Constructor and Description |
|---|
PreparedStatementWrapper(ManagedConnection con,
PreparedStatement stmt,
StatementKey statementKey,
String sql)
Creates a wrapper for a prepared statement.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearParameters()
Clears the current parameter values immediately.
|
void |
close()
Closes this statement.
|
protected void |
detachSession()
Detach the db from the connection.
Statements detach the db on executeUpdate or on close() in the resultsetwrapper after executeQuery. |
protected int |
effectivePosition(int p)
Gets the effective position.
This the p + columnOffset. |
ResultSetWrapper |
executeQuery()
Executes the query.
|
ResultSetWrapper |
executeQuery(boolean withinTx)
Executes the query.
|
protected ResultSet |
executeQueryImpl(String sql)
Implementation of executeQuery.
|
int |
executeUpdate()
Executes the update.
|
protected int |
executeUpdateImpl(String sql)
Implementation of executeUpdate.
|
int |
getColumnOffset()
Gets the column offset.
|
Object |
getParameter(int p)
Gets the parameter at position.
|
Map<Integer,Object> |
getParameters()
Gets the parameter map.
|
PreparedStatement |
getStatement()
Gets the wrapped prepared statement.
|
StatementKey |
getStatementKey()
Gets the statement key.
|
protected void |
rememberParameter(int p,
Object value)
Sets the parameter to be remembered for diagnostics.
|
void |
setBigDecimal(int p,
BigDecimal d) |
void |
setBinary(int p,
org.tentackle.common.Binary<?> b)
Sets the designated parameter to the given
Binary value. |
void |
setBMoney(int p,
org.tentackle.common.BMoney m)
Sets the designated parameter to a
BMoney value.A BMoney will not be stored as a single field but as two fields: a double representing the value an int representing the scale This is due to most DBMS can't store arbitrary scaled decimals in a single column, i.e. |
void |
setBoolean(int p,
boolean b) |
void |
setBoolean(int p,
Boolean b) |
void |
setByte(int p,
byte b) |
void |
setByte(int p,
Byte b) |
void |
setChar(int p,
char c) |
void |
setCharacter(int p,
Character c) |
void |
setCharacter(int p,
Character c,
boolean mapNull) |
void |
setColumnOffset(int columnOffset)
Sets the column offset.
|
void |
setDate(int p,
Date d) |
void |
setDate(int p,
Date d,
boolean mapNull) |
void |
setDate(int p,
Date d,
Calendar timezone) |
void |
setDate(int p,
Date d,
Calendar timezone,
boolean mapNull) |
void |
setDMoney(int p,
org.tentackle.common.DMoney m)
Sets the designated parameter to a
DMoney value.A DMoney will not be stored as a single field but as two fields: a BigDecimal with a scale of 0 representing the value an int representing the scale This is due to most DBMS can't store arbitrary scaled decimals in a single column, i.e. |
void |
setDouble(int p,
double d) |
void |
setDouble(int p,
Double d) |
void |
setFloat(int p,
float f) |
void |
setFloat(int p,
Float f) |
void |
setInt(int p,
int i) |
void |
setInteger(int p,
Integer i) |
void |
setLong(int p,
long l) |
void |
setLong(int p,
Long l) |
void |
setNull(int p,
int type) |
void |
setShort(int p,
short s) |
void |
setShort(int p,
Short s) |
void |
setString(int p,
String s) |
void |
setString(int p,
String s,
boolean mapNull) |
void |
setTime(int p,
Time t) |
void |
setTime(int p,
Time t,
Calendar timezone) |
void |
setTimestamp(int p,
Timestamp ts) |
void |
setTimestamp(int p,
Timestamp ts,
boolean mapNull) |
void |
setTimestamp(int p,
Timestamp ts,
Calendar timezone) |
void |
setTimestamp(int p,
Timestamp ts,
Calendar timezone,
boolean mapNull) |
String |
toString() |
assertNotReadOnly, assertOpen, cancel, consume, executeQuery, executeQuery, executeUpdate, forceDetached, getConnection, getFetchDirection, getFetchSize, getMaxRows, getSession, getSql, isCancelled, isClosed, isMarkedReady, isRunning, markReady, setFetchDirection, setFetchSize, setMaxRows, setRunning, unmarkReadypublic PreparedStatementWrapper(ManagedConnection con, PreparedStatement stmt, StatementKey statementKey, String sql)
con - the connectionstmt - the jdbc statementstatementKey - the statement key if not a one-shotsql - the original sql string that created the stmtpublic String toString()
toString in class StatementWrapperpublic void close()
StatementWrapperclose in interface AutoCloseableclose in class StatementWrapperpublic PreparedStatement getStatement()
getStatement in class StatementWrapperpublic StatementKey getStatementKey()
public void setColumnOffset(int columnOffset)
columnOffset - (default is 0)public int getColumnOffset()
protected int effectivePosition(int p)
p - the sql positionprotected void rememberParameter(int p,
Object value)
p - the effective sql positionvalue - the value of the parameterprotected void detachSession()
StatementWrapperdetachSession in class StatementWrapperpublic void clearParameters()
PreparedStatement.clearParameters()public Object getParameter(int p)
p - the sql positionpublic Map<Integer,Object> getParameters()
protected int executeUpdateImpl(String sql) throws SQLException
Overridden because sql-string isn't used.
executeUpdateImpl in class StatementWrappersql - the sql stringSQLException - if update failespublic int executeUpdate()
protected ResultSet executeQueryImpl(String sql) throws SQLException
Overridden because sql-string isn't used.
executeQueryImpl in class StatementWrappersql - the sql stringSQLException - if query failedpublic ResultSetWrapper executeQuery(boolean withinTx)
withinTx - is true if start a transaction for this query.public ResultSetWrapper executeQuery()
public void setNull(int p,
int type)
setNull in interface BackendPreparedStatementpublic void setString(int p,
String s,
boolean mapNull)
setString in interface BackendPreparedStatementpublic void setString(int p,
String s)
setString in interface BackendPreparedStatementpublic void setBoolean(int p,
boolean b)
setBoolean in interface BackendPreparedStatementpublic void setBoolean(int p,
Boolean b)
setBoolean in interface BackendPreparedStatementpublic void setByte(int p,
byte b)
setByte in interface BackendPreparedStatementpublic void setByte(int p,
Byte b)
setByte in interface BackendPreparedStatementpublic void setChar(int p,
char c)
setChar in interface BackendPreparedStatementpublic void setCharacter(int p,
Character c,
boolean mapNull)
setCharacter in interface BackendPreparedStatementpublic void setCharacter(int p,
Character c)
setCharacter in interface BackendPreparedStatementpublic void setShort(int p,
short s)
setShort in interface BackendPreparedStatementpublic void setShort(int p,
Short s)
setShort in interface BackendPreparedStatementpublic void setInt(int p,
int i)
setInt in interface BackendPreparedStatementpublic void setInteger(int p,
Integer i)
setInteger in interface BackendPreparedStatementpublic void setLong(int p,
long l)
setLong in interface BackendPreparedStatementpublic void setLong(int p,
Long l)
setLong in interface BackendPreparedStatementpublic void setFloat(int p,
float f)
setFloat in interface BackendPreparedStatementpublic void setFloat(int p,
Float f)
setFloat in interface BackendPreparedStatementpublic void setDouble(int p,
double d)
setDouble in interface BackendPreparedStatementpublic void setDouble(int p,
Double d)
setDouble in interface BackendPreparedStatementpublic void setBigDecimal(int p,
BigDecimal d)
setBigDecimal in interface BackendPreparedStatementpublic void setBMoney(int p,
org.tentackle.common.BMoney m)
BMoney value.p - the sql positionm - the money value, null to set SQL NULLsetDMoney(int, DMoney)public void setDMoney(int p,
org.tentackle.common.DMoney m)
DMoney value.p - the sql positionm - the money value, null to set SQL NULLsetBMoney(int, BMoney)public void setDate(int p,
Date d,
Calendar timezone,
boolean mapNull)
setDate in interface BackendPreparedStatementpublic void setDate(int p,
Date d,
Calendar timezone)
setDate in interface BackendPreparedStatementpublic void setDate(int p,
Date d,
boolean mapNull)
setDate in interface BackendPreparedStatementpublic void setDate(int p,
Date d)
setDate in interface BackendPreparedStatementpublic void setTimestamp(int p,
Timestamp ts,
Calendar timezone,
boolean mapNull)
setTimestamp in interface BackendPreparedStatementpublic void setTimestamp(int p,
Timestamp ts,
Calendar timezone)
setTimestamp in interface BackendPreparedStatementpublic void setTimestamp(int p,
Timestamp ts,
boolean mapNull)
setTimestamp in interface BackendPreparedStatementpublic void setTimestamp(int p,
Timestamp ts)
setTimestamp in interface BackendPreparedStatementpublic void setTime(int p,
Time t,
Calendar timezone)
setTime in interface BackendPreparedStatementpublic void setTime(int p,
Time t)
setTime in interface BackendPreparedStatementpublic void setBinary(int p,
org.tentackle.common.Binary<?> b)
Binary value.
will
The driver converts this to an SQL BLOB value when it sends it to the
database.
The implementation translates the Binary into an Inputstream and invokes
PreparedStatement.setBinaryStream(int, java.io.InputStream, int).p - the first parameter is 1, the second is 2, ...b - the parameter value, null if the value should be set to SQL NULLCopyright © 2016 Krake Softwaretechnik. All rights reserved.