Class NamedPreparedStatement
java.lang.Object
ch.cern.eam.wshub.core.services.grids.jdbc.NamedPreparedStatement
* @author adam_crume
-
Constructor Summary
ConstructorsConstructorDescriptionNamedPreparedStatement(Connection connection, String query) Creates a NamedParameterStatement. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBatch()Adds the current set of parameters as a batch entry.voidclose()Closes the statement.voiddefineParamters(String gridName, String sqlStatement, NamedPreparedStatement p, Credentials credentials, Map<String, Object> params) booleanexecute()Executes the statement.int[]Executes all of the batched statements.Executes the statement, which must be a query.intExecutes the statement, which must be an SQL INSERT, UPDATE or DELETE statement; or an SQL statement that returns nothing, such as a DDL statement.Returns the underlying statement.voidSets a parameter.voidSets a parameter.voidSets a parameter.voidSets a parameter.voidsetTimestamp(String name, Timestamp value) Sets a parameter.
-
Constructor Details
-
NamedPreparedStatement
Creates a NamedParameterStatement. Wraps a call to c.prepareStatement.- Parameters:
connection- the database connectionquery- the parameterized query- Throws:
SQLException- if the statement could not be created
-
-
Method Details
-
setObject
Sets a parameter.- Parameters:
name- parameter namevalue- parameter value- Throws:
SQLException- if an error occurredIllegalArgumentException- if the parameter does not exist- See Also:
-
setString
Sets a parameter.- Parameters:
name- parameter namevalue- parameter value- Throws:
SQLException- if an error occurredIllegalArgumentException- if the parameter does not exist- See Also:
-
setInt
Sets a parameter.- Parameters:
name- parameter namevalue- parameter value- Throws:
SQLException- if an error occurredIllegalArgumentException- if the parameter does not exist- See Also:
-
setLong
Sets a parameter.- Parameters:
name- parameter namevalue- parameter value- Throws:
SQLException- if an error occurredIllegalArgumentException- if the parameter does not exist- See Also:
-
setTimestamp
Sets a parameter.- Parameters:
name- parameter namevalue- parameter value- Throws:
SQLException- if an error occurredIllegalArgumentException- if the parameter does not exist- See Also:
-
getStatement
Returns the underlying statement.- Returns:
- the statement
-
execute
Executes the statement.- Returns:
- true if the first result is a
ResultSet - Throws:
SQLException- if an error occurred- See Also:
-
executeQuery
Executes the statement, which must be a query.- Returns:
- the query results
- Throws:
SQLException- if an error occurred- See Also:
-
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.- Returns:
- number of rows affected
- Throws:
SQLException- if an error occurred- See Also:
-
close
Closes the statement.- Throws:
SQLException- if an error occurred- See Also:
-
addBatch
Adds the current set of parameters as a batch entry.- Throws:
SQLException- if something went wrong
-
executeBatch
Executes all of the batched statements. SeeStatement.executeBatch()for details.- Returns:
- update counts for each statement
- Throws:
SQLException- if something went wrong
-
defineParamters
public void defineParamters(String gridName, String sqlStatement, NamedPreparedStatement p, Credentials credentials, Map<String, Object> params) throws SQLException- Throws:
SQLException
-