com.googlecode.jdbw.impl
Class SQLExecutorImpl
java.lang.Object
com.googlecode.jdbw.impl.SQLExecutorImpl
- All Implemented Interfaces:
- SQLExecutor
public abstract class SQLExecutorImpl
- extends Object
- implements SQLExecutor
This class is an implementation of the SQLExecutor that provides
most of the functionality required for sending queries and receiving data.
This class does not deal with setting up and tearing down database
connections; rather it expects the user to pass in a valid connection and
close it when done.
Normally, you wouldn't use this class directly, but rather through
classes such as the AutoExecutor or the DatabaseTransaction,
which is using this class behind the scenes. You call methods on
DatabaseConnection to get one of those.
- Author:
- Martin Berglund
- See Also:
AutoExecutor,
DatabaseTransaction,
DatabaseConnection
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
connection
protected final Connection connection
SQLExecutorImpl
protected SQLExecutorImpl(Connection connection)
execute
public void execute(ExecuteResultHandler handler,
String SQL,
Object... parameters)
throws SQLException
- Description copied from interface:
SQLExecutor
- Sends a query to the database and handles any results through a callback interface
- Specified by:
execute in interface SQLExecutor
- Parameters:
handler - Callback interface to use for any results of the querySQL - SQL code to send to the database server, use ? for parameter substitutionparameters - List of parameters to insert into the query, must be one for every ? used
- Throws:
SQLException
batchWrite
public void batchWrite(BatchUpdateHandler handler,
String SQL,
List<Object[]> parameters)
throws SQLException
- Description copied from interface:
SQLExecutor
- Executes a batch query where the SQL is structurally the same but parameters
are different. Usefull for inserting, updating or deleting multiple rows
from the same table.
- Specified by:
batchWrite in interface SQLExecutor
- Parameters:
handler - Callback interface to use for any results of the querySQL - SQL to use for all queries, use ? for the parameter substitutionparameters - List of object arrays, where one array equals one query sent to the server
- Throws:
SQLException
batchWrite
public void batchWrite(BatchUpdateHandler handler,
List<String> batchedSQL)
throws SQLException
- Description copied from interface:
SQLExecutor
- Executes a list of queries as one batch on the remote database server
- Specified by:
batchWrite in interface SQLExecutor
- Parameters:
handler - Callback interface to use for any results of the querybatchedSQL - List of SQL to send to the remote server
- Throws:
SQLException
prepareQueryStatement
protected PreparedStatement prepareQueryStatement(String SQL)
throws SQLException
- Throws:
SQLException
prepareInsertStatement
protected PreparedStatement prepareInsertStatement(String SQL)
throws SQLException
- Throws:
SQLException
prepareBatchUpdateStatement
protected PreparedStatement prepareBatchUpdateStatement(String SQL)
throws SQLException
- Throws:
SQLException
prepareExecuteStatement
protected PreparedStatement prepareExecuteStatement(String SQL)
throws SQLException
- Throws:
SQLException
executeUpdate
protected void executeUpdate(Statement statement,
String SQL)
throws SQLException
- Throws:
SQLException
getGeneratedKeys
protected ResultSet getGeneratedKeys(Statement statement)
throws SQLException
- Throws:
SQLException
setParameter
protected void setParameter(PreparedStatement statement,
Object object,
int i)
throws SQLException
- Throws:
SQLException
Copyright © 2012. All Rights Reserved.