public class FieldNamedPreparedStatementImpl extends Object implements FieldNamedPreparedStatement
FieldNamedPreparedStatement
.Modifier and Type | Method and Description |
---|---|
void |
addBatch()
Adds a set of parameters to this
NamedPreparedStatement object's batch of
commands. |
void |
clearParameters()
Clears the current parameter values immediately.
|
void |
close()
Releases this
Statement object's database and JDBC resources immediately instead
of waiting for this to happen when it is automatically closed. |
int[] |
executeBatch()
Submits a batch of commands to the database for execution and if all commands execute
successfully, returns an array of update counts.
|
ResultSet |
executeQuery()
Executes the SQL query in this
NamedPreparedStatement object and returns the
ResultSet object generated by the query. |
static String |
parseNamedStatement(String sql,
Map<String,List<Integer>> paramMap)
Parses a sql with named parameters.
|
static FieldNamedPreparedStatement |
prepareStatement(Connection connection,
String sql,
String[] fieldNames)
Creates a
NamedPreparedStatement object for sending parameterized SQL statements
to the database. |
void |
setBigDecimal(int fieldIndex,
BigDecimal x)
Sets the designated parameter to the given
java.math.BigDecimal value. |
void |
setBoolean(int fieldIndex,
boolean x)
Sets the designated parameter to the given Java
boolean value. |
void |
setByte(int fieldIndex,
byte x)
Sets the designated parameter to the given Java
byte value. |
void |
setBytes(int fieldIndex,
byte[] x)
Sets the designated parameter to the given Java array of bytes.
|
void |
setDate(int fieldIndex,
Date x)
Sets the designated parameter to the given
java.sql.Date value using the default
time zone of the virtual machine that is running the application. |
void |
setDouble(int fieldIndex,
double x)
Sets the designated parameter to the given Java
double value. |
void |
setFloat(int fieldIndex,
float x)
Sets the designated parameter to the given Java
float value. |
void |
setInt(int fieldIndex,
int x)
Sets the designated parameter to the given Java
int value. |
void |
setLong(int fieldIndex,
long x)
Sets the designated parameter to the given Java
long value. |
void |
setNull(int fieldIndex,
int sqlType)
Sets the designated parameter to SQL
NULL . |
void |
setObject(int fieldIndex,
Object x)
Sets the value of the designated parameter using the given object.
|
void |
setShort(int fieldIndex,
short x)
Sets the designated parameter to the given Java
short value. |
void |
setString(int fieldIndex,
String x)
Sets the designated parameter to the given Java
String value. |
void |
setTime(int fieldIndex,
Time x)
Sets the designated parameter to the given
java.sql.Time value. |
void |
setTimestamp(int fieldIndex,
Timestamp x)
Sets the designated parameter to the given
java.sql.Timestamp value. |
public void clearParameters() throws SQLException
FieldNamedPreparedStatement
In general, parameter values remain in force for repeated use of a statement. Setting a
parameter value automatically clears its previous value. However, in some cases it is useful
to immediately release the resources used by the current parameter values; this can be done
by calling the method clearParameters
.
clearParameters
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.clearParameters()
public ResultSet executeQuery() throws SQLException
FieldNamedPreparedStatement
NamedPreparedStatement
object and returns the
ResultSet
object generated by the query.executeQuery
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.executeQuery()
public void addBatch() throws SQLException
FieldNamedPreparedStatement
NamedPreparedStatement
object's batch of
commands.addBatch
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.addBatch()
public int[] executeBatch() throws SQLException
FieldNamedPreparedStatement
int
elements of the array
that is returned are ordered to correspond to the commands in the batch, which are ordered
according to the order in which they were added to the batch.executeBatch
in interface FieldNamedPreparedStatement
SQLException
Statement.executeBatch()
public void setNull(int fieldIndex, int sqlType) throws SQLException
FieldNamedPreparedStatement
NULL
.
Note: You must specify the parameter's SQL type.
setNull
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.setNull(int, int)
public void setBoolean(int fieldIndex, boolean x) throws SQLException
FieldNamedPreparedStatement
boolean
value. The driver
converts this to an SQL BIT
or BOOLEAN
value when it sends it to
the database.setBoolean
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.setBoolean(int, boolean)
public void setByte(int fieldIndex, byte x) throws SQLException
FieldNamedPreparedStatement
byte
value. The driver converts
this to an SQL TINYINT
value when it sends it to the database.setByte
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.setByte(int, byte)
public void setShort(int fieldIndex, short x) throws SQLException
FieldNamedPreparedStatement
short
value. The driver converts
this to an SQL SMALLINT
value when it sends it to the database.setShort
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.setShort(int, short)
public void setInt(int fieldIndex, int x) throws SQLException
FieldNamedPreparedStatement
int
value. The driver converts
this to an SQL INTEGER
value when it sends it to the database.setInt
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.setInt(int, int)
public void setLong(int fieldIndex, long x) throws SQLException
FieldNamedPreparedStatement
long
value. The driver converts
this to an SQL BIGINT
value when it sends it to the database.setLong
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.setLong(int, long)
public void setFloat(int fieldIndex, float x) throws SQLException
FieldNamedPreparedStatement
float
value. The driver converts
this to an SQL REAL
value when it sends it to the database.setFloat
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.setFloat(int, float)
public void setDouble(int fieldIndex, double x) throws SQLException
FieldNamedPreparedStatement
double
value. The driver
converts this to an SQL DOUBLE
value when it sends it to the database.setDouble
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.setDouble(int, double)
public void setBigDecimal(int fieldIndex, BigDecimal x) throws SQLException
FieldNamedPreparedStatement
java.math.BigDecimal
value. The
driver converts this to an SQL NUMERIC
value when it sends it to the database.setBigDecimal
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.setBigDecimal(int, BigDecimal)
public void setString(int fieldIndex, String x) throws SQLException
FieldNamedPreparedStatement
String
value. The driver
converts this to an SQL VARCHAR
or LONGVARCHAR
value (depending on
the argument's size relative to the driver's limits on VARCHAR
values) when it
sends it to the database.setString
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.setString(int, String)
public void setBytes(int fieldIndex, byte[] x) throws SQLException
FieldNamedPreparedStatement
VARBINARY
or LONGVARBINARY
(depending on the argument's size
relative to the driver's limits on VARBINARY
values) when it sends it to the
database.setBytes
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.setBytes(int, byte[])
public void setDate(int fieldIndex, Date x) throws SQLException
FieldNamedPreparedStatement
java.sql.Date
value using the default
time zone of the virtual machine that is running the application. The driver converts this to
an SQL DATE
value when it sends it to the database.setDate
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.setDate(int, Date)
public void setTime(int fieldIndex, Time x) throws SQLException
FieldNamedPreparedStatement
java.sql.Time
value. The driver
converts this to an SQL TIME
value when it sends it to the database.setTime
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.setTime(int, Time)
public void setTimestamp(int fieldIndex, Timestamp x) throws SQLException
FieldNamedPreparedStatement
java.sql.Timestamp
value. The driver
converts this to an SQL TIMESTAMP
value when it sends it to the database.setTimestamp
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.setTimestamp(int, Timestamp)
public void setObject(int fieldIndex, Object x) throws SQLException
FieldNamedPreparedStatement
setObject
in interface FieldNamedPreparedStatement
SQLException
PreparedStatement.setObject(int, Object)
public void close() throws SQLException
FieldNamedPreparedStatement
Statement
object's database and JDBC resources immediately instead
of waiting for this to happen when it is automatically closed. It is generally good practice
to release resources as soon as you are finished with them to avoid tying up database
resources.close
in interface AutoCloseable
close
in interface FieldNamedPreparedStatement
SQLException
Statement.close()
public static FieldNamedPreparedStatement prepareStatement(Connection connection, String sql, String[] fieldNames) throws SQLException
FieldNamedPreparedStatement
NamedPreparedStatement
object for sending parameterized SQL statements
to the database.prepareStatement
in interface FieldNamedPreparedStatement
connection
- the connection used to connect to database.sql
- an SQL statement that may contain one or more ':fieldName' as parameter
placeholdersfieldNames
- the field names in schema order used as the parameter namesSQLException
public static String parseNamedStatement(String sql, Map<String,List<Integer>> paramMap)
sql
- sql to parseparamMap
- map to hold parameter-index mappingsCopyright © 2014–2021 The Apache Software Foundation. All rights reserved.