org.jboss.minerva.datasource
Class JDBCPoolDataSource

java.lang.Object
  |
  +--org.jboss.minerva.datasource.JDBCPoolDataSource
All Implemented Interfaces:
javax.sql.DataSource, javax.naming.spi.ObjectFactory, javax.naming.Referenceable

public class JDBCPoolDataSource
extends java.lang.Object
implements javax.sql.DataSource, javax.naming.Referenceable, javax.naming.spi.ObjectFactory

DataSource for non-transactional JDBC pools. This handles configuration parameters for both the pool and the JDBC driver. It is important that you set all the configuration parameters before you initialize the DataSource, and you must initialize it before you use it. All the configuration parameters are not documented here; you are instead referred to ObjectPool and JDBCConnectionFactory.

Version:
$Revision: 1.4 $
Author:
Aaron Mulder (ammulder@alumni.princeton.edu)
See Also:
ObjectPool, JDBCConnectionFactory

Constructor Summary
JDBCPoolDataSource()
          Creates a new JDBC pool data source.
 
Method Summary
 void close()
          Shuts down this data source and the underlying pool.
 java.sql.Connection getConnection()
          Gets a connection from the pool.
 java.sql.Connection getConnection(java.lang.String user, java.lang.String password)
          Gets a connection from the pool.
static JDBCPoolDataSource getDataSource(java.lang.String poolName)
          Gets a specific JDBC pool data source by pool name.
static java.util.Collection getDataSources()
          Gets all the current JDBC pool data sources.
 long getGCInterval()
           
 long getGCMinIdleTime()
           
 long getIdleTimeout()
           
 java.lang.String getJDBCPassword()
           
 java.util.Properties getJDBCProperties()
           
 java.lang.String getJDBCURL()
           
 java.lang.String getJDBCUser()
           
 java.lang.String getJNDIName()
          Gets the JNDI name this pool is bound to.
 int getLoginTimeout()
          This property is not used by this implementation.
 java.io.PrintWriter getLogWriter()
          Gets a log writer used to record pool events.
 float getMaxIdleTimeoutPercent()
           
 int getMaxSize()
           
 int getMinSize()
           
 java.lang.Object getObjectInstance(java.lang.Object obj, javax.naming.Name name, javax.naming.Context nameCtx, java.util.Hashtable environment)
          Decodes a reference to a specific pool data source.
 java.lang.String getPoolName()
           
 java.lang.String getPoolStatus()
          Returns a string describing the pool status (number of connections created, used, and maximum).
 javax.naming.Reference getReference()
          Gets a reference to this data source.
 void initialize()
          Initializes the pool.
 boolean isBlocking()
           
 boolean isGCEnabled()
           
 boolean isIdleTimeoutEnabled()
           
 boolean isInvalidateOnError()
           
 boolean isTimestampUsed()
           
 void setBlocking(boolean blocking)
           
 void setGCEnabled(boolean allowGC)
           
 void setGCInterval(long millis)
           
 void setGCMinIdleTime(long millis)
           
 void setIdleTimeout(long millis)
           
 void setIdleTimeoutEnabled(boolean allowShrinking)
           
 void setInvalidateOnError(boolean invalidate)
           
 void setJDBCPassword(java.lang.String password)
           
 void setJDBCProperties(java.util.Properties props)
           
 void setJDBCURL(java.lang.String url)
           
 void setJDBCUser(java.lang.String user)
           
 void setJNDIName(java.lang.String name)
          If you use this to set a JNDI name, this pool will be bound to that name using the default InitialContext.
 void setLoginTimeout(int timeout)
          This property is not used by this implementation.
 void setLogWriter(java.io.PrintWriter writer)
          Sets a log writer used to record pool events.
 void setMaxIdleTimeoutPercent(float percent)
           
 void setMaxSize(int size)
           
 void setMinSize(int size)
           
 void setPoolName(java.lang.String name)
           
 void setTimestampUsed(boolean timestamp)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCPoolDataSource

public JDBCPoolDataSource()
Creates a new JDBC pool data source. Be sure to configure it and then call initialize before you try to use it.
Method Detail

getDataSources

public static java.util.Collection getDataSources()
Gets all the current JDBC pool data sources.

getDataSource

public static JDBCPoolDataSource getDataSource(java.lang.String poolName)
Gets a specific JDBC pool data source by pool name.

setJNDIName

public void setJNDIName(java.lang.String name)
                 throws javax.naming.NamingException
If you use this to set a JNDI name, this pool will be bound to that name using the default InitialContext. You can also do this manually if you have additional requirements.

getJNDIName

public java.lang.String getJNDIName()
Gets the JNDI name this pool is bound to. Only valid if you used setJNDIName to bind it.
See Also:
setJNDIName(java.lang.String)

setJDBCURL

public void setJDBCURL(java.lang.String url)

getJDBCURL

public java.lang.String getJDBCURL()

setJDBCProperties

public void setJDBCProperties(java.util.Properties props)

getJDBCProperties

public java.util.Properties getJDBCProperties()

setJDBCUser

public void setJDBCUser(java.lang.String user)

getJDBCUser

public java.lang.String getJDBCUser()

setJDBCPassword

public void setJDBCPassword(java.lang.String password)

getJDBCPassword

public java.lang.String getJDBCPassword()

setPoolName

public void setPoolName(java.lang.String name)

getPoolName

public java.lang.String getPoolName()

setMinSize

public void setMinSize(int size)

getMinSize

public int getMinSize()

setMaxSize

public void setMaxSize(int size)

getMaxSize

public int getMaxSize()

setBlocking

public void setBlocking(boolean blocking)

isBlocking

public boolean isBlocking()

setIdleTimeoutEnabled

public void setIdleTimeoutEnabled(boolean allowShrinking)

isIdleTimeoutEnabled

public boolean isIdleTimeoutEnabled()

setGCEnabled

public void setGCEnabled(boolean allowGC)

isGCEnabled

public boolean isGCEnabled()

setMaxIdleTimeoutPercent

public void setMaxIdleTimeoutPercent(float percent)

getMaxIdleTimeoutPercent

public float getMaxIdleTimeoutPercent()

setIdleTimeout

public void setIdleTimeout(long millis)

getIdleTimeout

public long getIdleTimeout()

setGCMinIdleTime

public void setGCMinIdleTime(long millis)

getGCMinIdleTime

public long getGCMinIdleTime()

setGCInterval

public void setGCInterval(long millis)

getGCInterval

public long getGCInterval()

setInvalidateOnError

public void setInvalidateOnError(boolean invalidate)

isInvalidateOnError

public boolean isInvalidateOnError()

setTimestampUsed

public void setTimestampUsed(boolean timestamp)

isTimestampUsed

public boolean isTimestampUsed()

initialize

public void initialize()
Initializes the pool. You need to have configured all the pool and JDBC properties first.

getPoolStatus

public java.lang.String getPoolStatus()
Returns a string describing the pool status (number of connections created, used, and maximum).

close

public void close()
Shuts down this data source and the underlying pool. If you used setJNDI name to bind it in JNDI, it is unbound.

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Gets a connection from the pool.
Specified by:
getConnection in interface javax.sql.DataSource

getConnection

public java.sql.Connection getConnection(java.lang.String user,
                                         java.lang.String password)
                                  throws java.sql.SQLException
Gets a connection from the pool. If a new connection must be created, it will use the specified user name and password. If there is a connection available in the pool, it will be used, regardless of the user name and password use to created it initially.
Specified by:
getConnection in interface javax.sql.DataSource

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws java.sql.SQLException
Gets a log writer used to record pool events.
Specified by:
getLogWriter in interface javax.sql.DataSource

setLogWriter

public void setLogWriter(java.io.PrintWriter writer)
                  throws java.sql.SQLException
Sets a log writer used to record pool events.
Specified by:
setLogWriter in interface javax.sql.DataSource

getLoginTimeout

public int getLoginTimeout()
                    throws java.sql.SQLException
This property is not used by this implementation.
Specified by:
getLoginTimeout in interface javax.sql.DataSource

setLoginTimeout

public void setLoginTimeout(int timeout)
                     throws java.sql.SQLException
This property is not used by this implementation.
Specified by:
setLoginTimeout in interface javax.sql.DataSource

getReference

public javax.naming.Reference getReference()
Gets a reference to this data source.
Specified by:
getReference in interface javax.naming.Referenceable

getObjectInstance

public java.lang.Object getObjectInstance(java.lang.Object obj,
                                          javax.naming.Name name,
                                          javax.naming.Context nameCtx,
                                          java.util.Hashtable environment)
Decodes a reference to a specific pool data source.
Specified by:
getObjectInstance in interface javax.naming.spi.ObjectFactory


Copyright © 2000 The jBoss Organization. All Rights Reserved.