com.googlecode.jdbw
Class AutoExecutor

java.lang.Object
  extended by com.googlecode.jdbw.AutoExecutor
All Implemented Interfaces:
SQLExecutor

public class AutoExecutor
extends Object
implements SQLExecutor

An auto executor will automatically allocate a connection from the pool when its SQL methods are called and return the connection and all resources once done. If a query fails, it will investigate the error and retry if the error is judged to be retryable.

Author:
Martin Berglund

Constructor Summary
AutoExecutor(DataSource dataSource, DatabaseServerType serverType)
           
 
Method Summary
 void batchWrite(BatchUpdateHandler handler, List<String> batchedSQL)
          Executes a list of queries as one batch on the remote database server
 void batchWrite(BatchUpdateHandler handler, String SQL, List<Object[]> parameters)
          Executes a batch query where the SQL is structurally the same but parameters are different.
 void batchWrite(List<String> batchedSQL)
          Shortcut for calling batchWrite(new BatchUpdateHandlerAdapter(), batchedSQL);
 void batchWrite(String SQL, List<Object[]> parameters)
          Shortcut for calling batchWrite(new BatchUpdateHandlerAdapter(), batchedSQL, parameters);
 void execute(ExecuteResultHandler handler, String SQL, Object... parameters)
          Sends a query to the database and handles any results through a callback interface
 void execute(String SQL, Object... parameters)
          Shortcut for calling execute(new ExecuteResultHandlerAdapter(), SQL, parameters);
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutoExecutor

public AutoExecutor(DataSource dataSource,
                    DatabaseServerType serverType)
Method Detail

execute

public void execute(String SQL,
                    Object... parameters)
             throws SQLException
Shortcut for calling execute(new ExecuteResultHandlerAdapter(), SQL, parameters);

Throws:
SQLException

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 query
SQL - SQL code to send to the database server, use ? for parameter substitution
parameters - List of parameters to insert into the query, must be one for every ? used
Throws:
SQLException

batchWrite

public void batchWrite(String SQL,
                       List<Object[]> parameters)
                throws SQLException
Shortcut for calling batchWrite(new BatchUpdateHandlerAdapter(), batchedSQL, parameters);

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 query
SQL - SQL to use for all queries, use ? for the parameter substitution
parameters - List of object arrays, where one array equals one query sent to the server
Throws:
SQLException

batchWrite

public void batchWrite(List<String> batchedSQL)
                throws SQLException
Shortcut for calling batchWrite(new BatchUpdateHandlerAdapter(), batchedSQL);

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 query
batchedSQL - List of SQL to send to the remote server
Throws:
SQLException


Copyright © 2012. All Rights Reserved.