Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.mentawai.db
Class C3P0ConnectionHandler  view C3P0ConnectionHandler download C3P0ConnectionHandler.java

java.lang.Object
  extended byorg.mentawai.db.C3P0ConnectionHandler
All Implemented Interfaces:
ConnectionHandler

public class C3P0ConnectionHandler
extends java.lang.Object
implements ConnectionHandler

A connection handler that uses the C3P0 connection pool. (http://sourceforge.net/projects/c3p0) To use this class you must have the C3P0 jar in your /WEB-INF/lib directory. You may access the underlying C3P0's ComboPooledDataSource to configure the pool, before you start calling getConnection().


Field Summary
private  javax.sql.DataSource cpds
           
 
Constructor Summary
C3P0ConnectionHandler(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String pass)
          Constructs a C3P0ConnectionHandler with C3P0's ComboPooledDataSource.
 
Method Summary
 javax.sql.DataSource getComboPooledDataSource()
          Gets the underlying C3P0's ComboPooledDataSource.
 java.sql.Connection getConnection()
          Returns a Connection to the database.
 void release(java.sql.Connection conn)
          Release this connection.
private  void setValue(java.lang.Object bean, java.lang.String name, java.lang.Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cpds

private javax.sql.DataSource cpds
Constructor Detail

C3P0ConnectionHandler

public C3P0ConnectionHandler(java.lang.String driver,
                             java.lang.String url,
                             java.lang.String user,
                             java.lang.String pass)
Constructs a C3P0ConnectionHandler with C3P0's ComboPooledDataSource.

Method Detail

setValue

private void setValue(java.lang.Object bean,
                      java.lang.String name,
                      java.lang.Object value)
               throws java.lang.Exception

getComboPooledDataSource

public javax.sql.DataSource getComboPooledDataSource()
Gets the underlying C3P0's ComboPooledDataSource.


getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Description copied from interface: ConnectionHandler
Returns a Connection to the database. Notice that it can never return null. If no connection can be acquired, then a SQLException is thrown.

Specified by:
getConnection in interface ConnectionHandler

release

public void release(java.sql.Connection conn)
Description copied from interface: ConnectionHandler
Release this connection. If this connection handler is using a database pool, the connection is returned to the pool. If this connection handler is not using a database pool, the connection is closed. If the connection passed as an argument is null, nothing is done.

Specified by:
release in interface ConnectionHandler