Hi.
c3p0 can handle a database's automatic expiration of Connections, in several ways:
1) You can set a maxIdleTime parameter so that old, idle Connections are automatically purged by the pool;
2) You can configure Connection testing, so that Connections are periodically tested by the pool (either prior to Connection checkout, or else frequently while idle), and purged if expired;
Please see the section of c3p0's docs regarding Connection testing.
Please note also that c3p0's default Connection test is slow -- I strongly recommend your setting the "preferredTestQuery" or "automaticTestTable" parameters. For MySQL, I have heard that setting preferredTestQuery to "SELECT 1" is a good approach. (Thanks to Mark Matthews -- see
http://lists.mysql.com/java/8119 .)
Please also see c3p0's documentation of configuring c3p0 parameters from hibernate. (5 parameters MUST be configured in your hibernate config; other parameters should be defined in a file called c3p0.properties.)
(The latest c3p0 release -- 0.8.5 (final) -- includes expanded documentation of these issues.)
smiles,
Steve (c3p0 guy)