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 provides just the name of the JDBC2 datasource to use in obtaining a connection from the JNDI context.

Author:
__AUTHOR__
See Also:
DatabaseProxy

Field Summary
static java.lang.String ABOUT
          CVS info about this class and its current version
protected static org.apache.log4j.Category logger
          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 executeQuery(java.lang.String dataSourceName, java.lang.String sql, java.util.List params)
          Execute the supplied SQL query against the supplied database connection.
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)
          Deprecated. Use ConnectionFactory.getConnection(Provider) instead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.apache.log4j.Category logger
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

See Also:
Constant Field Values
Constructor Detail

DataSourceProxy

public DataSourceProxy()
Method Detail

getConnection

public static java.sql.Connection getConnection(java.lang.String dataSourceName)
                                         throws DBException
Deprecated. Use ConnectionFactory.getConnection(Provider) instead.

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
DBException

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.

executeQuery

public static java.util.List executeQuery(java.lang.String dataSourceName,
                                          java.lang.String sql,
                                          java.util.List params)
                                   throws DBException
Execute the supplied SQL query against the supplied database connection.

Parameters:
dataSourceName - The datasource name to lookup in order to get a connection
sql - The SQL query to execute
params - List containing parameters to insert in the sql statement.
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 © 1999-2004 enableIT.org. All Rights Reserved.