*/
public void testConnectionLeakInDatabaseMetaData()
throws SQLException {
ConnectionPoolDataSource cpDs =
J2EEDataSource.getConnectionPoolDataSource();
PooledConnection pc = cpDs.getPooledConnection();
// Get first logical connection and a meta data object.
Connection con1 = pc.getConnection();
DatabaseMetaData dmd1 = con1.getMetaData();
assertSame(con1, dmd1.getConnection());
con1.close();
// Get second logical connection and a meta data object.
Connection con2 = pc.getConnection();
DatabaseMetaData dmd2 = con2.getMetaData();
// The first meta data object should not return a reference to the
// second logical connection.
assertSame(con2, dmd2.getConnection());
try {
dmd1.getConnection();
fail("Should have thrown no current connection exception");
} catch (SQLException sqle) {
assertSQLState("08003", sqle);
}
con2.close();
pc.close();
try {
dmd2.getConnection();
fail("Should have thrown no current connection exception");
} catch (SQLException sqle) {
assertSQLState("08003", sqle);