pl.kernelpanic.dbmonster.connection
Class DBCPConnectionProvider

java.lang.Object
  extended bypl.kernelpanic.dbmonster.connection.DBCPConnectionProvider
All Implemented Interfaces:
ConnectionProvider, LogEnabled

public class DBCPConnectionProvider
extends Object
implements ConnectionProvider, LogEnabled

The connection provider which uses commons-dbcp. It uses the following properties to establish connection:

By default these properties are taken from System.getProperty, but you may also provide them on your own.

Version:
$Id: DBCPConnectionProvider.html,v 1.1 2007/06/21 08:38:14 sbahloul Exp $
Author:
Piotr Maj

Constructor Summary
DBCPConnectionProvider()
          Creates new SimpleConnectionProvider.
DBCPConnectionProvider(String jdbcDriver, String jdbcUrl, Properties props)
          Creates new DBCPConnectionProvider with properties (usefull for interbase).
DBCPConnectionProvider(String jdbcDriver, String jdbcUrl, String jdbcUsername, String jdbcPassword)
          Creates new DBCPConnectionProvider with given connection info.
 
Method Summary
 Connection getConnection()
          Returns a JDBC connection.
 void setLogger(Log log)
          Sets the logger.
 void shutdown()
          Shutdown this connection provider.
 void testConnection()
          Tests a connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBCPConnectionProvider

public DBCPConnectionProvider()
                       throws Exception
Creates new SimpleConnectionProvider.

Throws:
Exception - if driver class could not be found.

DBCPConnectionProvider

public DBCPConnectionProvider(String jdbcDriver,
                              String jdbcUrl,
                              String jdbcUsername,
                              String jdbcPassword)
                       throws Exception
Creates new DBCPConnectionProvider with given connection info.

Parameters:
jdbcDriver - JDBC driver
jdbcUrl - JDBC url
jdbcUsername - JDBC user name
jdbcPassword - JDBC password
Throws:
Exception - if the driver class could not be found.

DBCPConnectionProvider

public DBCPConnectionProvider(String jdbcDriver,
                              String jdbcUrl,
                              Properties props)
                       throws Exception
Creates new DBCPConnectionProvider with properties (usefull for interbase).

Parameters:
jdbcDriver - JDBC driver
jdbcUrl - JDBC url
props - properties
Throws:
Exception - if driver class could not be found.
Method Detail

getConnection

public final Connection getConnection()
                               throws SQLException
Description copied from interface: ConnectionProvider
Returns a JDBC connection.

Specified by:
getConnection in interface ConnectionProvider
Returns:
JDBC connection
Throws:
SQLException - if connection cannot be obtained.
See Also:
ConnectionProvider.getConnection()

testConnection

public final void testConnection()
                          throws SQLException
Description copied from interface: ConnectionProvider
Tests a connection.

Specified by:
testConnection in interface ConnectionProvider
Throws:
SQLException - if connection could not be tested.
See Also:
ConnectionProvider.testConnection()

setLogger

public final void setLogger(Log log)
Sets the logger.

Specified by:
setLogger in interface LogEnabled
Parameters:
log - a logger.

shutdown

public final void shutdown()
Shutdown this connection provider.

Specified by:
shutdown in interface ConnectionProvider


Copyright © 2003-2005 .:. kernelpanic.pl .:.. All Rights Reserved.