- All Implemented Interfaces:
- public class PooledDataSourceObjectFactory
- extends BaseObjectFactory
This ObjectFactory uses the c3p0 connection pooling implementation to pool JDBC connections.
To use this factory, the c3p0 library (jar) MUST be in the classpath. c3p0 is NOT part
of the OOC distribution.
The following options may be passed to c3p0 via refAddrs. All options must include the
prefix "c3p0." in order for them to be passed to c3p0. The following list of options
is directly quoted from the com.mchange.v2.c3p0.PoolConfig
|Property Name||Built-In Default||Comments|
||If this is a number greater than 0, c3p0 will test all idle, pooled but unchecked-out connections, every this number of seconds.
||Seconds a Connection can remain pooled but unused before being discarded. Zero means idle connections never expire.
||The size of c3p0's PreparedStatement cache. Zero means statement cahing is turned off.
||Maximum time in seconds before user configuration constraints are enforced.
c3p0 enforces configuration constraints continually, and ignores this parameter.
It is included for JDBC 3 completeness.
||Determines how many connections at a time c3p0 will try to acquire when the pool is exhausted.
||Don't use. Very expensive.
If true, an operation will be performed at every connection checkout to verify that the connection is valid.
Better choice: verify connections periodically using c3p0.idleConnectionTestPeriod
||The JDBC spec is unforgivably silent on what should happen to unresolved, pending
transactions on Connection close. C3P0's default policy is to rollback any uncommitted, pending
work. (I think this is absolutely, undeniably the right policy, but there is no consensus among JDBC driver vendors.)
Setting autoCommitOnClose to true causes uncommitted pending work to be committed, rather than rolled
back on Connection close. [Note: Since the spec is absurdly unclear on this question, application authors who wish
to avoid bugs and inconsistent behavior should ensure that all transactions are explicitly either committed or
rolled-back before close is called.]
||Strongly disrecommended. Setting this to true may lead to subtle and bizarre bugs.
This is a terrible setting, leave it alone unless absolutely necessary. It is here to workaround
broken databases / JDBC drivers that do not properly support transactions, but that allow Connections'
autoCommit flags to go to false regardless. If you are using a database that supports transactions
"partially" (this is oxymoronic, as the whole point of transactions is to perform operations reliably and
completely, but nonetheless such databases are out there), if you feel comfortable ignoring the fact that Connections
with autoCommit == false may be in the middle of transactions and may hold locks and other resources,
you may turn off c3p0's wise default behavior, which is to protect itself, as well as the usability and consistency
of the database, by either rolling back (default) or committing (see c3p0.autoCommitOnClose above)
unresolved transactions. This should only be set to true when you are sure you are using a database that
allows Connections' autoCommit flag to go to false, but offers no other meaningful support of transactions. Otherwise
setting this to true is just a bad idea.
||com.mchange. v2.c3p0.impl. DefaultConnectionTester
||c3p0 is very asynchronous. Slow JDBC operations are generally
performed by helper threads that don't hold contended locks. Spreading
these operations over multiple threads can significantly improve performance
by allowing multiple operations to be performed simultaneously.
||DataSources that will be bound by JNDI and use that API's Referenceable interface
to store themselves may specify a URL from which the class capable of dereferencing
a them may be loaded. If (as is usually the case) the c3p0 libraries will be locally
available to the JNDI service, leave this set as null.
- $Revision: 1.4 $
- Jeff Drost
|Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public static final java.lang.String PARAM_DATA_SOURCE
- See Also:
- Constant Field Values
public java.lang.Object getObjectInstance(java.util.Properties properties,
getObjectInstance in class