public class NamedParameterStatement
extends java.lang.Object
| Constructor and Description |
|---|
NamedParameterStatement(java.sql.Connection connection,
java.lang.String query)
Creates a NamedParameterStatement.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBatch()
Adds the current set of parameters as a batch entry.
|
void |
close()
Closes the statement.
|
boolean |
execute()
Executes the statement.
|
int[] |
executeBatch()
Executes all of the batched statements.
|
java.sql.ResultSet |
executeQuery()
Executes the statement, which must be a query.
|
int |
executeUpdate()
Executes the statement, which must be an SQL INSERT, UPDATE or DELETE
statement; or an SQL statement that returns nothing, such as a DDL
statement.
|
java.sql.PreparedStatement |
getStatement()
Returns the underlying statement.
|
void |
setInt(java.lang.String name,
int value)
Sets a parameter.
|
void |
setLong(java.lang.String name,
long value)
Sets a parameter.
|
void |
setObject(java.lang.String name,
java.lang.Object value)
Sets a parameter.
|
void |
setString(java.lang.String name,
java.lang.String value)
Sets a parameter.
|
void |
setTimestamp(java.lang.String name,
java.sql.Timestamp value)
Sets a parameter.
|
public NamedParameterStatement(java.sql.Connection connection,
java.lang.String query)
throws java.sql.SQLException
prepareStatement.connection - the database connectionquery - the parameterized queryjava.sql.SQLException - if the statement could not be createdpublic void setObject(java.lang.String name,
java.lang.Object value)
throws java.sql.SQLException
name - parameter namevalue - parameter valuejava.sql.SQLException - if an error occurredjava.lang.IllegalArgumentException - if the parameter does not existPreparedStatement.setObject(int, java.lang.Object)public void setString(java.lang.String name,
java.lang.String value)
throws java.sql.SQLException
name - parameter namevalue - parameter valuejava.sql.SQLException - if an error occurredjava.lang.IllegalArgumentException - if the parameter does not existPreparedStatement.setString(int, java.lang.String)public void setInt(java.lang.String name,
int value)
throws java.sql.SQLException
name - parameter namevalue - parameter valuejava.sql.SQLException - if an error occurredjava.lang.IllegalArgumentException - if the parameter does not existPreparedStatement.setInt(int, int)public void setLong(java.lang.String name,
long value)
throws java.sql.SQLException
name - parameter namevalue - parameter valuejava.sql.SQLException - if an error occurredjava.lang.IllegalArgumentException - if the parameter does not existPreparedStatement.setInt(int, int)public void setTimestamp(java.lang.String name,
java.sql.Timestamp value)
throws java.sql.SQLException
name - parameter namevalue - parameter valuejava.sql.SQLException - if an error occurredjava.lang.IllegalArgumentException - if the parameter does not existPreparedStatement.setTimestamp(int, java.sql.Timestamp)public java.sql.PreparedStatement getStatement()
public boolean execute()
throws java.sql.SQLException
ResultSetjava.sql.SQLException - if an error occurredPreparedStatement.execute()public java.sql.ResultSet executeQuery()
throws java.sql.SQLException
java.sql.SQLException - if an error occurredPreparedStatement.executeQuery()public int executeUpdate()
throws java.sql.SQLException
java.sql.SQLException - if an error occurredPreparedStatement.executeUpdate()public void close()
throws java.sql.SQLException
java.sql.SQLException - if an error occurredStatement.close()public void addBatch()
throws java.sql.SQLException
java.sql.SQLException - if something went wrongpublic int[] executeBatch()
throws java.sql.SQLException
Statement.executeBatch() for details.java.sql.SQLException - if something went wrong