org.apache.lokahi.core.common.interfaces
Class GenericDatabaseBroker<T extends Dao>

java.lang.Object
  extended by org.apache.lokahi.core.common.interfaces.GenericDatabaseBroker<T>
Direct Known Subclasses:
DerbyBroker, OracleBroker

public abstract class GenericDatabaseBroker<T extends Dao>
extends java.lang.Object

Base class for interaction with sql databases.

Currently implements methods to build callable statements and build singular objects from the result set.

Version:
$Id: GenericDatabaseBroker.java,v 1.4 2006/03/07 22:05:24 drtobes Exp $
Author:
Stephen Toback

Constructor Summary
GenericDatabaseBroker()
           
 
Method Summary
protected  java.sql.CallableStatement buildParams(java.sql.CallableStatement csmt, boolean returns, int returnType, java.lang.Object... params)
          Builds the parameter list for a CallableStatement object based upon the parameters passed, currently supports only objects of Integer, String, and byte[] (for blobs) types.
protected  T fillObject(java.lang.Class<T> c, java.sql.ResultSet r)
          Finds and calls the appropriate fillObject for the given class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericDatabaseBroker

public GenericDatabaseBroker()
Method Detail

buildParams

protected java.sql.CallableStatement buildParams(java.sql.CallableStatement csmt,
                                                 boolean returns,
                                                 int returnType,
                                                 java.lang.Object... params)
                                          throws java.sql.SQLException
Builds the parameter list for a CallableStatement object based upon the parameters passed, currently supports only objects of Integer, String, and byte[] (for blobs) types.

Prevents the need to explictitly code all CallableStatements

Parameters:
csmt -
returns - true if the statement being built returns any value
returnType - as specified by the jdbc driver
params - passed to the stored procedure or function
Returns:
built CallableStatement populated with the objects in params
Throws:
java.sql.SQLException

fillObject

protected T fillObject(java.lang.Class<T> c,
                       java.sql.ResultSet r)
Finds and calls the appropriate fillObject for the given class

Parameters:
c - Class that must implements the Dao interface that the returned object is expected to be.
r - ResultSet to build the object out of
Returns:
populated object of Class T or null