public class NamedParameterStatement extends Object
Constructor and Description |
---|
NamedParameterStatement(Connection connection,
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.
|
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.
|
PreparedStatement |
getStatement()
Returns the underlying statement.
|
void |
setInt(String name,
int value)
Sets a parameter.
|
void |
setLong(String name,
long value)
Sets a parameter.
|
void |
setObject(String name,
Object value)
Sets a parameter.
|
void |
setString(String name,
String value)
Sets a parameter.
|
void |
setTimestamp(String name,
Timestamp value)
Sets a parameter.
|
public NamedParameterStatement(Connection connection, String query) throws SQLException
prepareStatement
.connection
- the database connectionquery
- the parameterized querySQLException
- if the statement could not be createdpublic void setObject(String name, Object value) throws SQLException
name
- parameter namevalue
- parameter valueSQLException
- if an error occurredIllegalArgumentException
- if the parameter does not existPreparedStatement.setObject(int, java.lang.Object)
public void setString(String name, String value) throws SQLException
name
- parameter namevalue
- parameter valueSQLException
- if an error occurredIllegalArgumentException
- if the parameter does not existPreparedStatement.setString(int, java.lang.String)
public void setInt(String name, int value) throws SQLException
name
- parameter namevalue
- parameter valueSQLException
- if an error occurredIllegalArgumentException
- if the parameter does not existPreparedStatement.setInt(int, int)
public void setLong(String name, long value) throws SQLException
name
- parameter namevalue
- parameter valueSQLException
- if an error occurredIllegalArgumentException
- if the parameter does not existPreparedStatement.setInt(int, int)
public void setTimestamp(String name, Timestamp value) throws SQLException
name
- parameter namevalue
- parameter valueSQLException
- if an error occurredIllegalArgumentException
- if the parameter does not existPreparedStatement.setTimestamp(int, java.sql.Timestamp)
public PreparedStatement getStatement()
public boolean execute() throws SQLException
ResultSet
SQLException
- if an error occurredPreparedStatement.execute()
public ResultSet executeQuery() throws SQLException
SQLException
- if an error occurredPreparedStatement.executeQuery()
public int executeUpdate() throws SQLException
SQLException
- if an error occurredPreparedStatement.executeUpdate()
public void close() throws SQLException
SQLException
- if an error occurredStatement.close()
public void addBatch() throws SQLException
SQLException
- if something went wrongpublic int[] executeBatch() throws SQLException
Statement.executeBatch()
for details.SQLException
- if something went wrongCopyright © 2019. All Rights Reserved.