The Encog Project

org.encog.util.db
Class RepeatableStatement

java.lang.Object
  extended by org.encog.util.db.RepeatableStatement

public class RepeatableStatement
extends java.lang.Object

RepeatableStatement: This class implements a repeatable statement. A repeatable statement is a regular PreparedStatement that can be repeated if the connection fails. Additionally, the repeatable statement maintains a cache of PreparedStatement objects for the threads. This prevents two threads from using the same PreparedStatement at the same time. To obtain a PreparedStatement a thread should call the obtainStatement function. Once the thread no longer needs the statement, the releaseStatement method should be called.


Nested Class Summary
 class RepeatableStatement.Results
          Simple internal class that holds the ResultSet from a query.
 
Constructor Summary
RepeatableStatement(java.lang.String sql)
          Construct a repeatable statement based on the specified SQL
 
Method Summary
 void close()
           
 void execute(java.lang.Object... parameters)
          Execute SQL that does not return a result set.
 RepeatableStatement.Results executeQuery(java.lang.Object... parameters)
          Execute an SQL query that returns a result set.
 void init(RepeatableConnection manager)
          Create the statement, so that it is ready to assign PreparedStatements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepeatableStatement

public RepeatableStatement(java.lang.String sql)
Construct a repeatable statement based on the specified SQL

Parameters:
sql - The SQL to base this statement on.
Method Detail

close

public void close()

init

public void init(RepeatableConnection manager)
Create the statement, so that it is ready to assign PreparedStatements.

Parameters:
manager - The manager that created this statement.
Throws:
java.sql.SQLException - Thrown if an exception occurs.

execute

public void execute(java.lang.Object... parameters)
Execute SQL that does not return a result set. If an error occurs, the statement will be retried until it is successful. This handles broken connections.

Parameters:
parameters - The parameters for this SQL.
Throws:
WorkloadException - Thrown if the SQL cannot be executed, and retrying the statement has failed.

executeQuery

public RepeatableStatement.Results executeQuery(java.lang.Object... parameters)
Execute an SQL query that returns a result set. If an error occurs, the statement will be retried until it is successful. This handles broken connections.

Parameters:
parameters - The parameters for this SQL.
Returns:
The results of the query.
Throws:
WorkloadException - Thrown if the SQL cannot be executed, and retrying the statement has failed.

The Encog Project