// Bugzilla Bug 27246
  // PreparedStatement cache should be different depending on the Catalog
  public void testPStmtCatalog() throws Exception {
    Connection conn = getConnection();
    conn.setCatalog("catalog1");
    DelegatingPreparedStatement stmt1 =
        (DelegatingPreparedStatement) conn.prepareStatement("select 'a' from dual");
    TesterPreparedStatement inner1 = (TesterPreparedStatement) stmt1.getInnermostDelegate();
    assertEquals("catalog1", inner1.getCatalog());
    stmt1.close();

    conn.setCatalog("catalog2");
    DelegatingPreparedStatement stmt2 =
        (DelegatingPreparedStatement) conn.prepareStatement("select 'a' from dual");
    TesterPreparedStatement inner2 = (TesterPreparedStatement) stmt2.getInnermostDelegate();
    assertEquals("catalog2", inner2.getCatalog());
    stmt2.close();

    conn.setCatalog("catalog1");
    DelegatingPreparedStatement stmt3 =
        (DelegatingPreparedStatement) conn.prepareStatement("select 'a' from dual");
    TesterPreparedStatement inner3 = (TesterPreparedStatement) stmt1.getInnermostDelegate();
    assertEquals("catalog1", inner3.getCatalog());
    stmt3.close();

    assertNotSame(inner1, inner2);
    assertSame(inner1, inner3);
  }
 /**
  * My {@link KeyedPoolableObjectFactory} method for destroying {@link PreparedStatement}s.
  *
  * @param key ignored
  * @param obj the {@link PreparedStatement} to be destroyed.
  */
 public void destroyObject(Object key, Object obj) throws Exception {
   // _openPstmts--;
   if (obj instanceof DelegatingPreparedStatement) {
     ((DelegatingPreparedStatement) obj).getInnermostDelegate().close();
   } else {
     ((PreparedStatement) obj).close();
   }
 }