org.enableit.db
Class DataSourceProxy

java.lang.Object
  |
  +--org.enableit.db.DataSourceProxy

public class DataSourceProxy
extends java.lang.Object

Proxy class to wrap database access in a simple form. The user is required to provide their own Connection

Version:
v1.2
Author:
chris.pettifer@enableit.org

Field Summary
static java.lang.String about
          CVS info about this class and its current version
protected static org.apache.log4j.Category cat
          The Log4J Category doing the logging.
 
Constructor Summary
DataSourceProxy()
           
 
Method Summary
static int executeDmlProcedure(java.lang.String dataSourceName, java.lang.String sp, java.util.List parms)
          Execute the supplied update procedure against a connection obtained from the named DataSource.
static java.util.List executeQuery(java.lang.String dataSourceName, java.lang.String sql)
          Execute the supplied SQL query against a connection obtained from the named DataSource.
static java.util.List executeQueryProcedure(java.lang.String dataSourceName, java.lang.String sp, java.util.List parms)
          Execute the supplied query procedure against a connection obtained from the named DataSource.
static int executeUpdate(java.lang.String dataSourceName, java.lang.String sql)
          Execute the supplied SQL update against a the supplied database connection.
static int executeUpdate(java.lang.String dataSourceName, java.lang.String sql, java.util.List parms)
          Execute the supplied SQL update against a connection obtained from the named DataSource.
static java.sql.Connection getConnection(java.lang.String dataSourceName)
          Get a connection from the named DataSource.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

cat

protected static org.apache.log4j.Category cat
The Log4J Category doing the logging. Same Category is used throughout the library.

about

public static final java.lang.String about
CVS info about this class and its current version
Constructor Detail

DataSourceProxy

public DataSourceProxy()
Method Detail

getConnection

public static java.sql.Connection getConnection(java.lang.String dataSourceName)
                                         throws DBException
Get a connection from the named DataSource. This method is intended for use by this class itself, but may be useful to other objects, in that case care must be taken to close the Connection properly.
Parameters:
dataSourceName - The DataSource to lookup to obtain a connection

executeQuery

public static java.util.List executeQuery(java.lang.String dataSourceName,
                                          java.lang.String sql)
                                   throws DBException
Execute the supplied SQL query against a connection obtained from the named DataSource.
Parameters:
dataSourceName - The datasource name to lookup in order to get a connection
sql - The SQL query to execute
Returns:
The SQL results stored as an java.util.ArrayList, each element of which is a java.util.TreeMap holding a single row of results
Throws:
DBException - If execution of the query failed.

executeUpdate

public static int executeUpdate(java.lang.String dataSourceName,
                                java.lang.String sql)
                         throws DBException
Execute the supplied SQL update against a the supplied database connection.
Parameters:
sql - The SQL update to execute
dataSourceName - The datasource name to lookup in order to get a connection
Returns:
The number of rows affected by the update.
Throws:
DBException - If execution of the update failed.

executeUpdate

public static int executeUpdate(java.lang.String dataSourceName,
                                java.lang.String sql,
                                java.util.List parms)
                         throws DBException
Execute the supplied SQL update against a connection obtained from the named DataSource.
Parameters:
dataSourceName - The datasource name to lookup in order to get a connection
sql - The SQL update to execute with parameters represented by ?
parms - ArrayList containing parameters to insert in the sql statement
Returns:
The number of rows affected by the update.
Throws:
DBException - If execution of the update failed.

executeDmlProcedure

public static int executeDmlProcedure(java.lang.String dataSourceName,
                                      java.lang.String sp,
                                      java.util.List parms)
                               throws DBException
Execute the supplied update procedure against a connection obtained from the named DataSource.
Parameters:
dataSourceName - The datasource name to lookup in order to get a connection
sp - A string containing the stored procedure name
parms - A java.util.List of String parameters for the stored procedure
Returns:
The number of rows affected by the stored procedure executed
Throws:
DBException - If execution of the stored procedure failed.

executeQueryProcedure

public static java.util.List executeQueryProcedure(java.lang.String dataSourceName,
                                                   java.lang.String sp,
                                                   java.util.List parms)
                                            throws DBException
Execute the supplied query procedure against a connection obtained from the named DataSource.
Parameters:
dataSourceName - The datasource name to lookup in order to get a connection
sp - A string containing the stored procedure name
parms - A java.util.List of String parameters for the stored procedure
Returns:
The SQL results stored as an java.util.ArrayList, each element of which is a java.util.TreeMap holding a single row of results
Throws:
DBException - If execution of the stored procedure failed.


Copyright © enableIT.org 1999,2000,2001,2002 All Rights Reserved.