cuba.wired
Class WiredPooledDataSource

java.lang.Object
  extended by cuba.wired.WiredPooledDataSource
All Implemented Interfaces:
ResourceFactoryI, WiredDataSourceI, javax.sql.DataSource

public class WiredPooledDataSource
extends java.lang.Object

The WiredPooledDataSource is a derivation of WiredDataSource which supports connection pooling to speed up database access over multiple component method calls.

Author:
Jan Lessner

Field Summary
protected  DataSourceDesc desc
           
protected  java.util.LinkedList freePool
          The list of free physical connections currently available
protected  int poolSize
          The total number of connections being pooled in this SQLSource
 
Method Summary
 void dropConnection(WiredManagedConnection mcon)
          Called by the transaction manager to signal that the passed connection is no longer in use.
 java.sql.Connection getConnection()
           
 java.sql.Connection getConnection(java.lang.String userName, java.lang.String password)
           
 int getLoginTimeout()
           
 java.io.PrintWriter getLogWriter()
           
 int getPoolSize()
          Only for test and analysis purposes
protected  java.sql.Connection newConnection()
          Get a new physical database connection from the DriverManager class.
 WiredManagedConnection nextConnection()
          Returns the next available free physical connection, wrapped in a new WiredManagedConnection.
 void setLoginTimeout(int seconds)
           
 void setLogWriter(java.io.PrintWriter out)
           
protected  void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

freePool

protected java.util.LinkedList freePool
The list of free physical connections currently available


poolSize

protected int poolSize
The total number of connections being pooled in this SQLSource


desc

protected DataSourceDesc desc
Method Detail

nextConnection

public WiredManagedConnection nextConnection()
                                      throws java.sql.SQLException
Returns the next available free physical connection, wrapped in a new WiredManagedConnection.

Specified by:
nextConnection in interface WiredDataSourceI
Throws:
java.sql.SQLException

dropConnection

public void dropConnection(WiredManagedConnection mcon)
                    throws ComponentException
Called by the transaction manager to signal that the passed connection is no longer in use. If the connection is marked to be invalid due to an error situation during usage, the whole connection pool is discarded. Otherwise the physical connection is just put back into the free pool.

Specified by:
dropConnection in interface WiredDataSourceI
Throws:
ComponentException

shutdown

protected void shutdown()

getPoolSize

public int getPoolSize()
Only for test and analysis purposes


newConnection

protected java.sql.Connection newConnection()
                                     throws java.sql.SQLException
Get a new physical database connection from the DriverManager class.

Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Specified by:
getConnection in interface javax.sql.DataSource
Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection(java.lang.String userName,
                                         java.lang.String password)
Specified by:
getConnection in interface javax.sql.DataSource

getLoginTimeout

public int getLoginTimeout()
                    throws java.sql.SQLException
Specified by:
getLoginTimeout in interface javax.sql.DataSource
Throws:
java.sql.SQLException

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws java.sql.SQLException
Specified by:
getLogWriter in interface javax.sql.DataSource
Throws:
java.sql.SQLException

setLoginTimeout

public void setLoginTimeout(int seconds)
                     throws java.sql.SQLException
Specified by:
setLoginTimeout in interface javax.sql.DataSource
Throws:
java.sql.SQLException

setLogWriter

public void setLogWriter(java.io.PrintWriter out)
                  throws java.sql.SQLException
Specified by:
setLogWriter in interface javax.sql.DataSource
Throws:
java.sql.SQLException