|
Awake SQL v1.2.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.awakefw.sql.api.util.PreparedStatementRunner
public class PreparedStatementRunner
Wrapper class for all kind of prepared statement: query or update
Update and Delete are safe because the WHERE clause is mandatory to prevent
dramatic errors.
Example:
// Get a JDBC Connection Connection connection = ... int customerId = 1; String sql = "select * from customer where customer_id = 1"; // Create the PreparedStatementRunner instance PreparedStatementRunner preparedStatementRunner = new PreparedStatementRunner( connection, sql, customerId); // Execute a query ResultSet rs = preparedStatementRunner.executeQuery(); ... ... // close the underlying ResultSet and PreparedStatement preparedStatementRunner.close();
Constructor Summary | |
---|---|
PreparedStatementRunner(Connection connection,
String sql,
Object... params)
Constructor. |
Method Summary | |
---|---|
void |
close()
Closes the PreparedStatementRunner. |
ResultSet |
executeQuery()
Executes a SQL prepared statement for a query. |
int |
executeUpdate()
Executes a SQL prepared statement for an update. |
String |
getDevelopedQuery()
Returns the developedQuery with substituted '?' |
String |
toString()
Returns a clean representation of the PreparedStatementRunner instance. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public PreparedStatementRunner(Connection connection, String sql, Object... params)
connection
- the JDBC Connection instancesql
- the prepared statement base sql request with all the '?'params
- the prepared statement parameters value in the awaited orderMethod Detail |
---|
public void close()
public ResultSet executeQuery() throws SQLException
SQLException
- if a SQL Exception is raisedpublic int executeUpdate() throws SQLException
SQLException
- if a SQL Exception is raisedpublic String getDevelopedQuery()
public String toString()
PreparedStatementRunner
instance.
toString
in class Object
PreparedStatementRunner
instance
|
Awake SQL v1.2.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |