wouvlfe,
The JMX mbean is the easiest approach. I'm not sure what sort of documentation you want, other than that it is there by default. If you run a JMX agent (like jconsole) on an app using 0.9.1, you'll find (under com.mchange.v2.c3p0) mbeans for each of your c3p0 PooledDataSource, and all config properties will be accessible from those mbeans.
The PoolConfig object only exists at initialization time; there's no way to get to it. c3p0 is architectured after the recommendations of the JDBC-spec, even where its author (me!) would have chosen to do things differently. One peculiarity of the JDBC-spec architecture (intended to make ConnectionPoolDataSources portable over pooling implementations, which is rarely useful in practice) is that most pool configuration data is stored as properties of the ConnectionPoolDataSource, rather than of the client-visible DataSource implementation. I probably should let the client DataSource serve as a "facade" through which you can access the underying config properties, but as of now, that's not there, except via the JMX mbean. You can get at this stuff. How you do it is sketched out below. It looks more complicated than it is. Unless you are doing something very unusual, either NORMAL CASE #1 or NORMAL CASE #2 will apply, and you'll have an object from which you can access config
properties.
Code:
import javax.sql.*;
import com.mchange.v2.c3p0.*;
import com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource;
DataSource ds = ...; //your c3p0 PooledDataSource
if ( ds instanceof ComboPooledDataSource )
{
// NORMAL CASE #1
ComboPooledDataSource cpds = (ComboPooledDataSource) ds;
...
// cpds has direct accessors for all config properties, check out
// the api docs for ComboPooledDataSource
}
else if (ds instanceof AbstractPoolBackedDataSource)
{
AbstractPoolBackedDataSource apbds = (AbstractPoolBackedDataSource) ds;
ConnectionPoolDataSource cpds = apbds.getConnectionPoolDataSource();
if (cpds instanceof WrapperConnectionPoolDataSource)
{
// NORMAL CASE #2
WrapperConnectionPoolDataSource wcpds = (WrapperConnectionPoolDataSource) cpds;
...
// cpds has direct accessors for most config properties, check out
// the api docs for WrapperConnectionPoolDataSource
}
else
{
// unusal -- you build a c3p0 PooledDataSource using your
// own ConnectionPoolDataSource implementation. You'd
// know it if you did this. c3p0-specific config properties are
// almost certainly the documented defaults. (If this is your
// situation -- very unlikely -- then ask, and I'll explain in
// more detail.
}
}
else
{
// not a c3p0-0.9.1-defined implementation
}
Good luck!
Steve