com.mchange.v2.c3p0
Class ComboPooledDataSource

java.lang.Object
  extended by com.mchange.v2.c3p0.impl.IdentityTokenResolvable
      extended by com.mchange.v2.c3p0.ComboPooledDataSource
All Implemented Interfaces:
com.mchange.v2.c3p0.impl.IdentityTokenized, PooledDataSource, java.io.Serializable, javax.naming.Referenceable, javax.sql.DataSource

public final class ComboPooledDataSource
extends com.mchange.v2.c3p0.impl.IdentityTokenResolvable
implements PooledDataSource, java.io.Serializable, javax.naming.Referenceable

For the meaning of most of these properties, please see PoolConfig!

See Also:
Serialized Form

Constructor Summary
ComboPooledDataSource()
           
 
Method Summary
 void close()
          C3P0 pooled DataSources use no resources before they are actually used in a VM, and they close themselves in their finalize() method.
 void close(boolean force_destroy)
          Should be used only with great caution.
 int getAcquireIncrement()
           
 int getAcquireRetryAttempts()
           
 int getAcquireRetryDelay()
           
 java.lang.String getAutomaticTestTable()
           
 int getCheckoutTimeout()
           
 java.sql.Connection getConnection()
           
 java.sql.Connection getConnection(java.lang.String username, java.lang.String password)
           
 java.lang.String getConnectionTesterClassName()
           
 java.lang.String getDescription()
           
 java.lang.String getDriverClass()
           
 java.lang.String getFactoryClassLocation()
           
 java.lang.String getIdentityToken()
           
 int getIdleConnectionTestPeriod()
           
 int getInitialPoolSize()
           
 java.lang.String getJdbcUrl()
           
 int getLoginTimeout()
           
 java.io.PrintWriter getLogWriter()
           
 int getMaxIdleTime()
           
 int getMaxPoolSize()
           
 int getMaxStatements()
           
 int getMaxStatementsPerConnection()
           
 int getMinPoolSize()
           
 int getNumBusyConnections()
           
 int getNumBusyConnections(java.lang.String username, java.lang.String password)
           
 int getNumBusyConnectionsAllUsers()
           
 int getNumBusyConnectionsDefaultUser()
           
 int getNumConnections()
           
 int getNumConnections(java.lang.String username, java.lang.String password)
           
 int getNumConnectionsAllUsers()
           
 int getNumConnectionsDefaultUser()
           
 int getNumHelperThreads()
           
 int getNumIdleConnections()
           
 int getNumIdleConnections(java.lang.String username, java.lang.String password)
           
 int getNumIdleConnectionsAllUsers()
           
 int getNumIdleConnectionsDefaultUser()
           
 int getNumUnclosedOrphanedConnections()
           
 int getNumUnclosedOrphanedConnections(java.lang.String username, java.lang.String password)
           
 int getNumUnclosedOrphanedConnectionsAllUsers()
           
 int getNumUnclosedOrphanedConnectionsDefaultUser()
           
 int getNumUserPools()
           
 java.lang.String getPassword()
           
 java.lang.String getPreferredTestQuery()
           
 java.util.Properties getProperties()
           
 int getPropertyCycle()
           
 javax.naming.Reference getReference()
           
 java.lang.String getUser()
           
 void hardReset()
          Destroys all pooled and checked-out Connections associated with this DataSource immediately.
 boolean isAutoCommitOnClose()
           
 boolean isBreakAfterAcquireFailure()
           
 boolean isForceIgnoreUnresolvedTransactions()
           
 boolean isTestConnectionOnCheckin()
           
 boolean isTestConnectionOnCheckout()
           
 boolean isUsesTraditionalReflectiveProxies()
           
 void setAcquireIncrement(int acquireIncrement)
           
 void setAcquireRetryAttempts(int acquireRetryAttempts)
           
 void setAcquireRetryDelay(int acquireRetryDelay)
           
 void setAutoCommitOnClose(boolean autoCommitOnClose)
           
 void setAutomaticTestTable(java.lang.String automaticTestTable)
           
 void setBreakAfterAcquireFailure(boolean breakAfterAcquireFailure)
           
 void setCheckoutTimeout(int checkoutTimeout)
           
 void setConnectionTesterClassName(java.lang.String connectionTesterClassName)
           
 void setDescription(java.lang.String description)
           
 void setDriverClass(java.lang.String driverClass)
           
 void setFactoryClassLocation(java.lang.String factoryClassLocation)
           
 void setForceIgnoreUnresolvedTransactions(boolean forceIgnoreUnresolvedTransactions)
           
 void setIdentityToken(java.lang.String identityToken)
           
 void setIdleConnectionTestPeriod(int idleConnectionTestPeriod)
           
 void setInitialPoolSize(int initialPoolSize)
           
 void setJdbcUrl(java.lang.String jdbcUrl)
           
 void setLoginTimeout(int seconds)
           
 void setLogWriter(java.io.PrintWriter out)
           
 void setMaxIdleTime(int maxIdleTime)
           
 void setMaxPoolSize(int maxPoolSize)
           
 void setMaxStatements(int maxStatements)
           
 void setMaxStatementsPerConnection(int maxStatementsPerConnection)
           
 void setMinPoolSize(int minPoolSize)
           
 void setNumHelperThreads(int numHelperThreads)
           
 void setPassword(java.lang.String password)
           
 void setPreferredTestQuery(java.lang.String preferredTestQuery)
           
 void setProperties(java.util.Properties properties)
           
 void setPropertyCycle(int propertyCycle)
           
 void setTestConnectionOnCheckin(boolean testConnectionOnCheckin)
           
 void setTestConnectionOnCheckout(boolean testConnectionOnCheckout)
           
 void setUser(java.lang.String user)
           
 void setUsesTraditionalReflectiveProxies(boolean usesTraditionalReflectiveProxies)
           
 void softReset(java.lang.String username, java.lang.String password)
          Discards all Connections managed by the PooledDataSource with the specified authentication credentials and reacquires new Connections to populate.
 void softResetAllUsers()
          Discards all Connections managed by the PooledDataSource and reacquires new Connections to populate.
 void softResetDefaultUser()
          Discards all Connections managed by the PooledDataSource's default-authentication pool and reacquires new Connections to populate.
 java.lang.String toString()
           
 
Methods inherited from class com.mchange.v2.c3p0.impl.IdentityTokenResolvable
doResolve, readResolve, verifyResolve
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComboPooledDataSource

public ComboPooledDataSource()
Method Detail

getDescription

public java.lang.String getDescription()

setDescription

public void setDescription(java.lang.String description)

getDriverClass

public java.lang.String getDriverClass()

setDriverClass

public void setDriverClass(java.lang.String driverClass)
                    throws java.beans.PropertyVetoException
Throws:
java.beans.PropertyVetoException

getJdbcUrl

public java.lang.String getJdbcUrl()

setJdbcUrl

public void setJdbcUrl(java.lang.String jdbcUrl)

getProperties

public java.util.Properties getProperties()

setProperties

public void setProperties(java.util.Properties properties)

getUser

public java.lang.String getUser()

setUser

public void setUser(java.lang.String user)

getPassword

public java.lang.String getPassword()

setPassword

public void setPassword(java.lang.String password)

getCheckoutTimeout

public int getCheckoutTimeout()

setCheckoutTimeout

public void setCheckoutTimeout(int checkoutTimeout)

getAcquireIncrement

public int getAcquireIncrement()

setAcquireIncrement

public void setAcquireIncrement(int acquireIncrement)

getAcquireRetryAttempts

public int getAcquireRetryAttempts()

setAcquireRetryAttempts

public void setAcquireRetryAttempts(int acquireRetryAttempts)

getAcquireRetryDelay

public int getAcquireRetryDelay()

setAcquireRetryDelay

public void setAcquireRetryDelay(int acquireRetryDelay)

isAutoCommitOnClose

public boolean isAutoCommitOnClose()

setAutoCommitOnClose

public void setAutoCommitOnClose(boolean autoCommitOnClose)

getConnectionTesterClassName

public java.lang.String getConnectionTesterClassName()

setConnectionTesterClassName

public void setConnectionTesterClassName(java.lang.String connectionTesterClassName)
                                  throws java.beans.PropertyVetoException
Throws:
java.beans.PropertyVetoException

getAutomaticTestTable

public java.lang.String getAutomaticTestTable()

setAutomaticTestTable

public void setAutomaticTestTable(java.lang.String automaticTestTable)

isForceIgnoreUnresolvedTransactions

public boolean isForceIgnoreUnresolvedTransactions()

setForceIgnoreUnresolvedTransactions

public void setForceIgnoreUnresolvedTransactions(boolean forceIgnoreUnresolvedTransactions)

getIdleConnectionTestPeriod

public int getIdleConnectionTestPeriod()

setIdleConnectionTestPeriod

public void setIdleConnectionTestPeriod(int idleConnectionTestPeriod)

getInitialPoolSize

public int getInitialPoolSize()

setInitialPoolSize

public void setInitialPoolSize(int initialPoolSize)

getMaxIdleTime

public int getMaxIdleTime()

setMaxIdleTime

public void setMaxIdleTime(int maxIdleTime)

getMaxPoolSize

public int getMaxPoolSize()

setMaxPoolSize

public void setMaxPoolSize(int maxPoolSize)

getMaxStatements

public int getMaxStatements()

setMaxStatements

public void setMaxStatements(int maxStatements)

getMaxStatementsPerConnection

public int getMaxStatementsPerConnection()

setMaxStatementsPerConnection

public void setMaxStatementsPerConnection(int maxStatementsPerConnection)

getMinPoolSize

public int getMinPoolSize()

setMinPoolSize

public void setMinPoolSize(int minPoolSize)

getPropertyCycle

public int getPropertyCycle()

setPropertyCycle

public void setPropertyCycle(int propertyCycle)

isBreakAfterAcquireFailure

public boolean isBreakAfterAcquireFailure()

setBreakAfterAcquireFailure

public void setBreakAfterAcquireFailure(boolean breakAfterAcquireFailure)

isTestConnectionOnCheckout

public boolean isTestConnectionOnCheckout()

setTestConnectionOnCheckout

public void setTestConnectionOnCheckout(boolean testConnectionOnCheckout)

isTestConnectionOnCheckin

public boolean isTestConnectionOnCheckin()

setTestConnectionOnCheckin

public void setTestConnectionOnCheckin(boolean testConnectionOnCheckin)

isUsesTraditionalReflectiveProxies

public boolean isUsesTraditionalReflectiveProxies()

setUsesTraditionalReflectiveProxies

public void setUsesTraditionalReflectiveProxies(boolean usesTraditionalReflectiveProxies)

getPreferredTestQuery

public java.lang.String getPreferredTestQuery()

setPreferredTestQuery

public void setPreferredTestQuery(java.lang.String preferredTestQuery)

getNumHelperThreads

public int getNumHelperThreads()

setNumHelperThreads

public void setNumHelperThreads(int numHelperThreads)

getIdentityToken

public java.lang.String getIdentityToken()
Specified by:
getIdentityToken in interface com.mchange.v2.c3p0.impl.IdentityTokenized

setIdentityToken

public void setIdentityToken(java.lang.String identityToken)
Specified by:
setIdentityToken in interface com.mchange.v2.c3p0.impl.IdentityTokenized

getFactoryClassLocation

public java.lang.String getFactoryClassLocation()

setFactoryClassLocation

public void setFactoryClassLocation(java.lang.String factoryClassLocation)

getReference

public javax.naming.Reference getReference()
                                    throws javax.naming.NamingException
Specified by:
getReference in interface javax.naming.Referenceable
Throws:
javax.naming.NamingException

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)
                                  throws java.sql.SQLException
Specified by:
getConnection 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

setLogWriter

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

getLoginTimeout

public int getLoginTimeout()
                    throws java.sql.SQLException
Specified by:
getLoginTimeout 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

getNumConnections

public int getNumConnections()
                      throws java.sql.SQLException
Specified by:
getNumConnections in interface PooledDataSource
Throws:
java.sql.SQLException

getNumIdleConnections

public int getNumIdleConnections()
                          throws java.sql.SQLException
Specified by:
getNumIdleConnections in interface PooledDataSource
Throws:
java.sql.SQLException

getNumBusyConnections

public int getNumBusyConnections()
                          throws java.sql.SQLException
Specified by:
getNumBusyConnections in interface PooledDataSource
Throws:
java.sql.SQLException

getNumUnclosedOrphanedConnections

public int getNumUnclosedOrphanedConnections()
                                      throws java.sql.SQLException
Specified by:
getNumUnclosedOrphanedConnections in interface PooledDataSource
Throws:
java.sql.SQLException

getNumConnectionsDefaultUser

public int getNumConnectionsDefaultUser()
                                 throws java.sql.SQLException
Specified by:
getNumConnectionsDefaultUser in interface PooledDataSource
Throws:
java.sql.SQLException

getNumIdleConnectionsDefaultUser

public int getNumIdleConnectionsDefaultUser()
                                     throws java.sql.SQLException
Specified by:
getNumIdleConnectionsDefaultUser in interface PooledDataSource
Throws:
java.sql.SQLException

getNumBusyConnectionsDefaultUser

public int getNumBusyConnectionsDefaultUser()
                                     throws java.sql.SQLException
Specified by:
getNumBusyConnectionsDefaultUser in interface PooledDataSource
Throws:
java.sql.SQLException

getNumUnclosedOrphanedConnectionsDefaultUser

public int getNumUnclosedOrphanedConnectionsDefaultUser()
                                                 throws java.sql.SQLException
Specified by:
getNumUnclosedOrphanedConnectionsDefaultUser in interface PooledDataSource
Throws:
java.sql.SQLException

softResetDefaultUser

public void softResetDefaultUser()
                          throws java.sql.SQLException
Description copied from interface: PooledDataSource
Discards all Connections managed by the PooledDataSource's default-authentication pool and reacquires new Connections to populate. Current checked out Connections will still be valid, and should still be checked into the PooledDataSource (so the PooledDataSource can destroy them).

Specified by:
softResetDefaultUser in interface PooledDataSource
Throws:
java.sql.SQLException

getNumConnections

public int getNumConnections(java.lang.String username,
                             java.lang.String password)
                      throws java.sql.SQLException
Specified by:
getNumConnections in interface PooledDataSource
Throws:
java.sql.SQLException

getNumIdleConnections

public int getNumIdleConnections(java.lang.String username,
                                 java.lang.String password)
                          throws java.sql.SQLException
Specified by:
getNumIdleConnections in interface PooledDataSource
Throws:
java.sql.SQLException

getNumBusyConnections

public int getNumBusyConnections(java.lang.String username,
                                 java.lang.String password)
                          throws java.sql.SQLException
Specified by:
getNumBusyConnections in interface PooledDataSource
Throws:
java.sql.SQLException

getNumUnclosedOrphanedConnections

public int getNumUnclosedOrphanedConnections(java.lang.String username,
                                             java.lang.String password)
                                      throws java.sql.SQLException
Specified by:
getNumUnclosedOrphanedConnections in interface PooledDataSource
Throws:
java.sql.SQLException

softReset

public void softReset(java.lang.String username,
                      java.lang.String password)
               throws java.sql.SQLException
Description copied from interface: PooledDataSource
Discards all Connections managed by the PooledDataSource with the specified authentication credentials and reacquires new Connections to populate. Current checked out Connections will still be valid, and should still be checked into the PooledDataSource (so the PooledDataSource can destroy them).

Specified by:
softReset in interface PooledDataSource
Throws:
java.sql.SQLException

getNumBusyConnectionsAllUsers

public int getNumBusyConnectionsAllUsers()
                                  throws java.sql.SQLException
Specified by:
getNumBusyConnectionsAllUsers in interface PooledDataSource
Throws:
java.sql.SQLException

getNumIdleConnectionsAllUsers

public int getNumIdleConnectionsAllUsers()
                                  throws java.sql.SQLException
Specified by:
getNumIdleConnectionsAllUsers in interface PooledDataSource
Throws:
java.sql.SQLException

getNumConnectionsAllUsers

public int getNumConnectionsAllUsers()
                              throws java.sql.SQLException
Specified by:
getNumConnectionsAllUsers in interface PooledDataSource
Throws:
java.sql.SQLException

getNumUnclosedOrphanedConnectionsAllUsers

public int getNumUnclosedOrphanedConnectionsAllUsers()
                                              throws java.sql.SQLException
Specified by:
getNumUnclosedOrphanedConnectionsAllUsers in interface PooledDataSource
Throws:
java.sql.SQLException

softResetAllUsers

public void softResetAllUsers()
                       throws java.sql.SQLException
Description copied from interface: PooledDataSource
Discards all Connections managed by the PooledDataSource and reacquires new Connections to populate. Current checked out Connections will still be valid, and should still be checked into the PooledDataSource (so the PooledDataSource can destroy them).

Specified by:
softResetAllUsers in interface PooledDataSource
Throws:
java.sql.SQLException

getNumUserPools

public int getNumUserPools()
                    throws java.sql.SQLException
Specified by:
getNumUserPools in interface PooledDataSource
Throws:
java.sql.SQLException

hardReset

public void hardReset()
               throws java.sql.SQLException
Description copied from interface: PooledDataSource
Destroys all pooled and checked-out Connections associated with this DataSource immediately. The PooledDataSource is reset to its initial state prior to first Connection acquisition, with no pools yet active, but ready for requests.

Specified by:
hardReset in interface PooledDataSource
Throws:
java.sql.SQLException

close

public void close()
           throws java.sql.SQLException
Description copied from interface: PooledDataSource

C3P0 pooled DataSources use no resources before they are actually used in a VM, and they close themselves in their finalize() method. When they are active and pooling, they may have open database connections and their pool may spawn several threads for its maintenance. You can use this method to clean these resource methods up quickly when you will no longer be using this DataSource. The resources will actually be cleaned up only if no other DataSources are sharing the same pool.

You can equivalently use the static method destroy() in the DataSources class to clean-up these resources.

This is equivalent to calling close( false ).

Specified by:
close in interface PooledDataSource
Throws:
java.sql.SQLException
See Also:
DataSources.destroy(javax.sql.DataSource)

close

public void close(boolean force_destroy)
           throws java.sql.SQLException
Description copied from interface: PooledDataSource

Should be used only with great caution. If force_destroy is set to true, this immediately destroys any pool and cleans up all resources this DataSource may be using, even if other DataSources are sharing that pool! In general, it is difficult to know whether a pool is being shared by multiple DataSources. It may depend upon whether or not a JNDI implementation returns a single instance or multiple copies upon lookup (which is undefined by the JNDI spec).

In general, this method should be used only when you wish to wind down all c3p0 pools in a ClassLoader. For example, when shutting down and restarting a web application that uses c3p0, you may wish to kill all threads making use of classes loaded by a web-app specific ClassLoader, so that the ClassLoader can be cleanly garbage collected. In this case, you may wish to use force destroy. Otherwise, it is much safer to use the simple destroy() method, which will not shut down pools that may still be in use.

To close a pool normally, use the no argument close method, or set force_destroy to false.

Specified by:
close in interface PooledDataSource
Throws:
java.sql.SQLException
See Also:
PooledDataSource.close()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object