org.apache.ojb.broker.util.batch
Class BatchConnection

java.lang.Object
  extended byorg.apache.ojb.broker.util.WrappedConnection
      extended byorg.apache.ojb.broker.util.batch.BatchConnection
All Implemented Interfaces:
java.sql.Connection

public class BatchConnection
extends WrappedConnection

The implementation of Connection which automatically gathers INSERT, UPDATE and DELETE PreparedStatements into batches.

Version:
$Id: BatchConnection.java,v 1.15 2004/01/18 16:47:01 olegnitz Exp $
Author:
Oleg Nitz (olegnitz@apache.org)

Field Summary
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
BatchConnection(java.sql.Connection conn, PersistenceBroker broker)
           
 
Method Summary
 void clearBatch()
           
 void commit()
           
 void executeBatch()
           
 void executeBatchIfNecessary()
           
(package private)  void nextExecuted(java.lang.String sql)
          Remember the order of execution
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
           
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
           
 void rollback()
           
 void setUseBatchInserts(boolean useBatchInserts)
           
 
Methods inherited from class org.apache.ojb.broker.util.WrappedConnection
activateConnection, checkOpen, clearWarnings, close, createStatement, createStatement, createStatement, getAutoCommit, getCatalog, getDelegate, getHoldability, getInnermostDelegate, getMetaData, getTransactionIsolation, getTypeMap, getWarnings, isClosed, isReadOnly, nativeSQL, passivateConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, setAutoCommit, setCatalog, setDelegate, setHoldability, setReadOnly, setSavepoint, setSavepoint, setTransactionIsolation, setTypeMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BatchConnection

public BatchConnection(java.sql.Connection conn,
                       PersistenceBroker broker)
Method Detail

setUseBatchInserts

public void setUseBatchInserts(boolean useBatchInserts)

nextExecuted

void nextExecuted(java.lang.String sql)
            throws java.sql.SQLException
Remember the order of execution

Throws:
java.sql.SQLException

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                            throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Overrides:
prepareStatement in class WrappedConnection
Throws:
java.sql.SQLException

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int resultSetType,
                                                   int resultSetConcurrency)
                                            throws java.sql.SQLException
Specified by:
prepareStatement in interface java.sql.Connection
Overrides:
prepareStatement in class WrappedConnection
Throws:
java.sql.SQLException

executeBatch

public void executeBatch()
                  throws java.sql.SQLException
Throws:
java.sql.SQLException

executeBatchIfNecessary

public void executeBatchIfNecessary()
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

clearBatch

public void clearBatch()

commit

public void commit()
            throws java.sql.SQLException
Specified by:
commit in interface java.sql.Connection
Overrides:
commit in class WrappedConnection
Throws:
java.sql.SQLException

rollback

public void rollback()
              throws java.sql.SQLException
Specified by:
rollback in interface java.sql.Connection
Overrides:
rollback in class WrappedConnection
Throws:
java.sql.SQLException


Authors: Thomas Mahler and others. (C) 2000 - 2003 Apache Software Foundation
All rights reserved. Published under the Apache License.
http://db.apache.org/ojb
Version: 1.0.rc5, 2003-12-14