// 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);
  }
 public boolean equals(Object obj) {
   PreparedStatement delegate = (PreparedStatement) getInnermostDelegate();
   if (delegate == null) {
     return false;
   }
   if (obj instanceof DelegatingPreparedStatement) {
     DelegatingPreparedStatement s = (DelegatingPreparedStatement) obj;
     return delegate.equals(s.getInnermostDelegate());
   } else {
     return delegate.equals(obj);
   }
 }
 /**
  * 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();
   }
 }
 /**
  * My {@link KeyedPoolableObjectFactory} method for passivating {@link PreparedStatement}s.
  * Currently invokes {@link PreparedStatement#clearParameters}.
  *
  * @param key ignored
  * @param obj a {@link PreparedStatement}
  */
 public void passivateObject(Object key, Object obj) throws Exception {
   ((PreparedStatement) obj).clearParameters();
   ((DelegatingPreparedStatement) obj).passivate();
 }
 /**
  * My {@link KeyedPoolableObjectFactory} method for activating {@link PreparedStatement}s.
  * (Currently a no-op.)
  *
  * @param key ignored
  * @param obj ignored
  */
 public void activateObject(Object key, Object obj) {
   ((DelegatingPreparedStatement) obj).activate();
 }
 /** Sets my delegate. */
 public void setDelegate(CallableStatement s) {
   super.setDelegate(s);
   _stmt = s;
 }