pl.kernelpanic.dbmonster.connection
Class SimpleConnectionProvider

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

public class SimpleConnectionProvider
extends Object
implements ConnectionProvider, LogEnabled

The most simple connection provider. It uses the following properies to establish connection:

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

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

Constructor Summary
SimpleConnectionProvider()
          Creates new SimpleConnectionProvider.
SimpleConnectionProvider(String jdbcDriver, String jdbcUrl, Properties props)
          Creates new SimpleConnectionProvider with properties (usefull for interbase).
SimpleConnectionProvider(String jdbcDriver, String jdbcUrl, String jdbcUsername, String jdbcPassword)
          Creates new SimpleConnectionProvider 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

SimpleConnectionProvider

public SimpleConnectionProvider()
                         throws ClassNotFoundException
Creates new SimpleConnectionProvider.

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

SimpleConnectionProvider

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

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

SimpleConnectionProvider

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

Parameters:
jdbcDriver - JDBC driver
jdbcUrl - JDBC url
props - properties
Throws:
ClassNotFoundException - 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.