net.sf.jguard.ext.database
Class ConnectionFactory

java.lang.Object
  extended by net.sf.jguard.ext.database.ConnectionFactory

public final class ConnectionFactory
extends java.lang.Object

Factory for Database Connection.

Version:
$Revision: 2976 $
Author:
Charles Gay

Constructor Summary
ConnectionFactory(javax.sql.DataSource dataSource)
          inject the Datasource with this constructor.
ConnectionFactory(java.util.Map opts)
          initialise connection settings for the specified webapp in the map (with the applicationName parameter).
 
Method Summary
 java.sql.Connection getConnection()
          Returns a database connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionFactory

public ConnectionFactory(javax.sql.DataSource dataSource)
inject the Datasource with this constructor. that's the IoC way.


ConnectionFactory

public ConnectionFactory(java.util.Map opts)
initialise connection settings for the specified webapp in the map (with the applicationName parameter).

Parameters:
opts -
Method Detail

getConnection

public java.sql.Connection getConnection()
Returns a database connection. Connection is pooled with DBCP when url,driver,login and password are set; otherwise, datasource is grabbed either with the injected Datasource (passe in the constructor), or via JNDI where the application server should have pooled it.

Returns:
java.sql.Connection obtained either from a pool or explicitly


Copyright © 2004-2009. All Rights Reserved.