phe,
Sorry you had problems with c3p0. I'm sorry about c3p0's unconfigurable logging to standard error; I think that's the library's weakest point. (this will hopefully be remedied c3p0-0.9.0, which will make use of JDK1.4 standard logging. but that'll come after c3p0-0.8.5 is finalized. c3p0-0.8.x is JDK1.3.x compatible.)
c3p0 does have quite extensive tools to permit you to ensure that Connections your application sees are not stale. By default, c3p0 does no Connection testing at all, because Connnection testing can be expensive. But c3p0 (as of v0.8.5-pre7 and above) provides the following parameters to permit as testing that is as cautious or as loose as you'd like:
c3p0.automaticTestTable
c3p0.preferredTestQuery
c3p0.testConnectionOnCheckin
c3p0.testConnectionOnCheckout [maps to hibernate.c3p0.validate]*
c3p0.idleConnectionTestPeriod [maps to hibernate.c3p0.idle_test_period]*
* NOTE that where hibernate maps c3p0 params to hibernate config params, hibernate users MUST use the hibernate versions, in your hibernate configuration, or your settings will be overridden by hibernate specified defaults! Other parameters should be specified in a file called c3p0.properties at the root of your application's effective CLASSPATH. [see
http://forum.hibernate.org/viewtopic.ph ... highlight= ]
To reproduce the behavior you are seeing with Proxool -- i.e. to have each Connection tested prior to checkout -- set hibernate.c3p0.validate to true in your hibernate configuration.
Testing every Connection on checkout is the most reliable, but also the most performance costly approach to Connection testing. If you do this with c3p0, I'd recommend you define c3p0.automaticTestTable or c3p0.preferredTestQuery, which may dramatically improve test performance. c3p0.automaticTestTable is the most convenient approach -- just set this to the name of a table c3p0 can create and use to run test queries against.
Another good approach to connection testing is to define c3p0.testConnectionOnCheckin and c3p0.idleConnectionTestPeriod. This is less reliable than testing in checkout, but has an advantage because check-in and idle tests are performed asynchronously by c3p0, and therefore less directly impact client performance. By setting both of these parameters, you can be assured that your Connection has been tested recently prior to a checkout, without putting the test synchronously in the client's code path. [In hibernate, do be sure to set hibernate.c3p0.idle_test_period in your hibernate config and c3p0.testConnectionOnCheckin separately in c3p0 properties file! See above!]
If you do try c3p0 again, there were a few issues with your configuration. The hibernate-mapped properties for controlling the pool's size are hibernate.c3p0.min_size and hibernate.c3p0.max_size. hibernate.c3p0.minPoolSize won't work. c3p0 dumps its configuration on initialization -- if you're having problems, it's a good idea to verify your configuration by double checking this. The hibernate-mapped property for controlling the statement cache size is hibernate.c3p0.max_statements, not hibernate.c3p0.max_statement. The minimum pool size has no impact on Connection testing and verification. c3p0 will cull bad Connections regardless of pool size if the idle check is turned on.
Anyway, I'm sorry you had problems with c3p0. Good luck!
Steve (c3p0 guy)