org.apache.ojb.broker.accesslayer
Class StatementManager

java.lang.Object
  extended by org.apache.ojb.broker.accesslayer.StatementManager
All Implemented Interfaces:
StatementManagerIF

public class StatementManager
extends java.lang.Object
implements StatementManagerIF

manages JDBC Connection and Statement resources.

Version:
$Id: StatementManager.java 364832 2005-06-04 14:15:37Z arminw $
Author:
Thomas Mahler, Randall Burt

Field Summary
 
Fields inherited from interface org.apache.ojb.broker.accesslayer.StatementManagerIF
FETCH_SIZE_NOT_APPLICABLE, FETCH_SIZE_NOT_EXPLICITLY_SET
 
Constructor Summary
StatementManager(PersistenceBroker pBroker)
           
 
Method Summary
 void bindDelete(java.sql.PreparedStatement stmt, ClassDescriptor cld, java.lang.Object obj)
          binds the objects primary key and locking values to the statement, BRJ
 void bindDelete(java.sql.PreparedStatement stmt, Identity oid, ClassDescriptor cld)
          binds the Identities Primary key values to the statement
 void bindInsert(java.sql.PreparedStatement stmt, ClassDescriptor cld, java.lang.Object obj)
          binds the values of the object obj to the statements parameters
 void bindSelect(java.sql.PreparedStatement stmt, Identity oid, ClassDescriptor cld, boolean callableStmt)
          Binds the Identities Primary key values to the statement.
 int bindStatement(java.sql.PreparedStatement stmt, Query query, ClassDescriptor cld, int param)
          bind a Query based Select Statement
 void bindUpdate(java.sql.PreparedStatement stmt, ClassDescriptor cld, java.lang.Object obj)
          binds the values of the object obj to the statements parameters
 int bindValues(java.sql.PreparedStatement stmt, ValueContainer[] values, int index)
          binds the given array of values (if not null) starting from the given parameter index
 void closeResources(java.sql.Statement stmt, java.sql.ResultSet rs)
           
 java.sql.PreparedStatement getDeleteStatement(ClassDescriptor cld)
          return a prepared DELETE Statement fitting for the given ClassDescriptor
 java.sql.Statement getGenericStatement(ClassDescriptor cds, boolean scrollable)
          return a generic Statement for the given ClassDescriptor.
 java.sql.PreparedStatement getInsertStatement(ClassDescriptor cds)
          return a prepared Insert Statement fitting for the given ClassDescriptor
 java.sql.PreparedStatement getPreparedStatement(ClassDescriptor cds, java.lang.String sql, boolean scrollable, int explicitFetchSizeHint, boolean callableStmt)
          return a generic Statement for the given ClassDescriptor
 java.sql.PreparedStatement getSelectByPKStatement(ClassDescriptor cds)
          return a prepared Select Statement for the given ClassDescriptor
 java.sql.PreparedStatement getUpdateStatement(ClassDescriptor cds)
          return a prepared Update Statement fitting to the given ClassDescriptor
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatementManager

public StatementManager(PersistenceBroker pBroker)
Method Detail

closeResources

public void closeResources(java.sql.Statement stmt,
                           java.sql.ResultSet rs)
Specified by:
closeResources in interface StatementManagerIF

bindDelete

public void bindDelete(java.sql.PreparedStatement stmt,
                       Identity oid,
                       ClassDescriptor cld)
                throws java.sql.SQLException
binds the Identities Primary key values to the statement

Specified by:
bindDelete in interface StatementManagerIF
cld - ClassDescriptor for the Object, if null will be lookup automatic
Throws:
java.sql.SQLException

bindDelete

public void bindDelete(java.sql.PreparedStatement stmt,
                       ClassDescriptor cld,
                       java.lang.Object obj)
                throws java.sql.SQLException
binds the objects primary key and locking values to the statement, BRJ

Specified by:
bindDelete in interface StatementManagerIF
Throws:
java.sql.SQLException

bindStatement

public int bindStatement(java.sql.PreparedStatement stmt,
                         Query query,
                         ClassDescriptor cld,
                         int param)
                  throws java.sql.SQLException
bind a Query based Select Statement

Specified by:
bindStatement in interface StatementManagerIF
Throws:
java.sql.SQLException

bindInsert

public void bindInsert(java.sql.PreparedStatement stmt,
                       ClassDescriptor cld,
                       java.lang.Object obj)
                throws java.sql.SQLException
binds the values of the object obj to the statements parameters

Specified by:
bindInsert in interface StatementManagerIF
Throws:
java.sql.SQLException

bindSelect

public void bindSelect(java.sql.PreparedStatement stmt,
                       Identity oid,
                       ClassDescriptor cld,
                       boolean callableStmt)
                throws java.sql.SQLException
Binds the Identities Primary key values to the statement.

Specified by:
bindSelect in interface StatementManagerIF
cld - ClassDescriptor for the Object, if null will be lookup automatic
callableStmt - Indicate if the specified PreparedStatement is a CallableStatement supporting stored procedures.
Throws:
java.sql.SQLException

bindUpdate

public void bindUpdate(java.sql.PreparedStatement stmt,
                       ClassDescriptor cld,
                       java.lang.Object obj)
                throws java.sql.SQLException
binds the values of the object obj to the statements parameters

Specified by:
bindUpdate in interface StatementManagerIF
Throws:
java.sql.SQLException

bindValues

public int bindValues(java.sql.PreparedStatement stmt,
                      ValueContainer[] values,
                      int index)
               throws java.sql.SQLException
binds the given array of values (if not null) starting from the given parameter index

Specified by:
bindValues in interface StatementManagerIF
Returns:
the next parameter index
Throws:
java.sql.SQLException

getDeleteStatement

public java.sql.PreparedStatement getDeleteStatement(ClassDescriptor cld)
                                              throws PersistenceBrokerSQLException,
                                                     PersistenceBrokerException
return a prepared DELETE Statement fitting for the given ClassDescriptor

Specified by:
getDeleteStatement in interface StatementManagerIF
Throws:
PersistenceBrokerSQLException
PersistenceBrokerException

getGenericStatement

public java.sql.Statement getGenericStatement(ClassDescriptor cds,
                                              boolean scrollable)
                                       throws PersistenceBrokerException
return a generic Statement for the given ClassDescriptor. Never use this method for UPDATE/INSERT/DELETE if you want to use the batch mode.

Specified by:
getGenericStatement in interface StatementManagerIF
Throws:
PersistenceBrokerException

getInsertStatement

public java.sql.PreparedStatement getInsertStatement(ClassDescriptor cds)
                                              throws PersistenceBrokerSQLException,
                                                     PersistenceBrokerException
return a prepared Insert Statement fitting for the given ClassDescriptor

Specified by:
getInsertStatement in interface StatementManagerIF
Throws:
PersistenceBrokerSQLException
PersistenceBrokerException

getPreparedStatement

public java.sql.PreparedStatement getPreparedStatement(ClassDescriptor cds,
                                                       java.lang.String sql,
                                                       boolean scrollable,
                                                       int explicitFetchSizeHint,
                                                       boolean callableStmt)
                                                throws PersistenceBrokerException
return a generic Statement for the given ClassDescriptor

Specified by:
getPreparedStatement in interface StatementManagerIF
Throws:
PersistenceBrokerException

getSelectByPKStatement

public java.sql.PreparedStatement getSelectByPKStatement(ClassDescriptor cds)
                                                  throws PersistenceBrokerSQLException,
                                                         PersistenceBrokerException
return a prepared Select Statement for the given ClassDescriptor

Specified by:
getSelectByPKStatement in interface StatementManagerIF
Throws:
PersistenceBrokerSQLException
PersistenceBrokerException

getUpdateStatement

public java.sql.PreparedStatement getUpdateStatement(ClassDescriptor cds)
                                              throws PersistenceBrokerSQLException,
                                                     PersistenceBrokerException
return a prepared Update Statement fitting to the given ClassDescriptor

Specified by:
getUpdateStatement in interface StatementManagerIF
Throws:
PersistenceBrokerSQLException
PersistenceBrokerException


(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30