public static class QueryPreparer.PlaceHolder extends SqlObject
appendTo
method is called. This enables the user
to set parameters correctly in a PreparedStatement where the position is
not known at query creation time.
Note: a PlaceHolder may not be used in more than one place in
the query. For this functionality, use QueryPreparer.MultiPlaceHolder
.ALL_SYMBOL, NULL_VALUE, QUESTION_MARK
Constructor and Description |
---|
PlaceHolder(QueryPreparer outer) |
Modifier and Type | Method and Description |
---|---|
protected void |
addIndex(int index) |
void |
appendTo(AppendableExt app)
Appends this object to the given AppendableExt.
|
protected void |
collectSchemaObjects(ValidationContext vContext)
Used during Query.validate() calls to collect the dbschema objects
referenced in a query.
|
int |
getIndex()
Returns the 1-based index of this PlaceHolder in the query.
|
List<Integer> |
getIndexes() |
protected QueryPreparer |
getOuter() |
boolean |
isInQuery()
Returns
true if this PlaceHolder was used in the query,
false otherwise. |
void |
setBoolean(boolean value,
PreparedStatement ps)
Calls setBoolean on the given PreparedStatement with the given value
for the position of this PlaceHolder.
|
void |
setBoolean(Boolean value,
PreparedStatement ps)
Calls setBoolean on the given PreparedStatement with the given value for
the position of this PlaceHolder.
|
void |
setInt(Integer value,
PreparedStatement ps)
Calls setInt on the given PreparedStatement with the given value for
the position of this PlaceHolder.
|
void |
setInt(int value,
PreparedStatement ps)
Calls setInt on the given PreparedStatement with the given value
for the position of this PlaceHolder.
|
void |
setLong(long value,
PreparedStatement ps)
Calls setLong on the given PreparedStatement with the given value
for the position of this PlaceHolder.
|
void |
setLong(Long value,
PreparedStatement ps)
Calls setLong on the given PreparedStatement with the given value for
the position of this PlaceHolder.
|
protected void |
setNonNullObject(Object value,
int sqlType,
PreparedStatement ps)
Calls setObject on the given PreparedStatement with the given value
and the given sql type for the position of this PlaceHolder.
|
protected void |
setNonNullString(String value,
PreparedStatement ps)
Calls setString on the given PreparedStatement with the given value
for the position of this PlaceHolder.
|
void |
setNull(int sqlType,
PreparedStatement ps)
Calls setNull on the given PreparedStatement with the given sql type
for the position of this PlaceHolder.
|
void |
setObject(Object value,
int sqlType,
PreparedStatement ps)
Calls setObject on the given PreparedStatement with the given value
and the given sql type for the position of this PlaceHolder.
|
void |
setObject(Object value,
PreparedStatement ps)
Calls setObject on the given PreparedStatement with the given value
for the position of this PlaceHolder.
|
void |
setString(String value,
PreparedStatement ps)
Calls setString on the given PreparedStatement with the given value
for the position of this PlaceHolder.
|
collectSchemaObjects, doValidate, toString
toString, toString
public PlaceHolder(QueryPreparer outer)
protected QueryPreparer getOuter()
public boolean isInQuery()
true
if this PlaceHolder was used in the query,
false
otherwise.public int getIndex()
protected void addIndex(int index)
public void setNull(int sqlType, PreparedStatement ps) throws SQLException
SQLException
public void setInt(int value, PreparedStatement ps) throws SQLException
SQLException
public void setInt(Integer value, PreparedStatement ps) throws SQLException
null
,
calls setNull with the sql type INTEGER
.SQLException
public void setLong(long value, PreparedStatement ps) throws SQLException
SQLException
public void setLong(Long value, PreparedStatement ps) throws SQLException
null
,
calls setNull with the sql type BIGINT
.SQLException
public void setBoolean(boolean value, PreparedStatement ps) throws SQLException
SQLException
public void setBoolean(Boolean value, PreparedStatement ps) throws SQLException
null
,
calls setNull with the sql type BOOLEAN
.SQLException
protected void setNonNullString(String value, PreparedStatement ps) throws SQLException
SQLException
public void setString(String value, PreparedStatement ps) throws SQLException
SQLException
public void setObject(Object value, PreparedStatement ps) throws SQLException
null
value may or may not
work, depending on the JDBC driver. The only reliable (across all JDBC
drivers) way to set a null
object is to call
setObject(Object,int,PreparedStatement)
with the correct SQL
type.SQLException
protected void setNonNullObject(Object value, int sqlType, PreparedStatement ps) throws SQLException
SQLException
public void setObject(Object value, int sqlType, PreparedStatement ps) throws SQLException
SQLException
protected void collectSchemaObjects(ValidationContext vContext)
SqlObject
collectSchemaObjects
in class SqlObject
vContext
- handle to the current validation contextpublic void appendTo(AppendableExt app) throws IOException
Appendee
appendTo
in interface Appendee
appendTo
in class AppendeeObject
app
- the AppendableExt to which this class should append itselfIOException
- if the append failsCopyright © 2006–2021 OpenHMS. All rights reserved.