public class CachedPreparedStatement extends Object
"SELECT * FROM person WHERE age > ?"
would have the integer
variable 18
(which replaces the "?" chracter) to find all adults. This class
encapsulates both the SQL string and bind variable values so that actual
PreparedStatement can be created from that information later.Constructor and Description |
---|
CachedPreparedStatement()
Constructs a new CachedPreparedStatement.
|
CachedPreparedStatement(String sql)
Constructs a new CachedPreparedStatement.
|
Modifier and Type | Method and Description |
---|---|
void |
addBoolean(boolean value)
Adds a boolean parameter to the prepared statement.
|
void |
addInt(int value)
Adds an integer parameter to the prepared statement.
|
void |
addLong(long value)
Adds a long parameter to the prepared statement.
|
void |
addString(String value)
Adds a String parameter to the prepared statement.
|
boolean |
equals(Object object) |
String |
getSQL()
Returns the SQL.
|
int |
hashCode() |
void |
setParams(PreparedStatement pstmt)
Sets all parameters on the given PreparedStatement.
|
void |
setSQL(String sql)
Sets the SQL.
|
String |
toString() |
public CachedPreparedStatement()
public CachedPreparedStatement(String sql)
sql
- the SQL.public String getSQL()
public void setSQL(String sql)
sql
- the SQL.public void addBoolean(boolean value)
value
- the boolean value.public void addInt(int value)
value
- the int value.public void addLong(long value)
value
- the long value.public void addString(String value)
value
- the String value.public void setParams(PreparedStatement pstmt) throws SQLException
PreparedStatement pstmt = con.prepareStatement(cachedPstmt.getSQL()); cachedPstmt.setParams(pstmt);
pstmt
- the prepared statement.SQLException
- if an SQL Exception occurs.Copyright © 2003–2020 Ignite Realtime. All rights reserved.