Hi, I'm quite confused about how to get prepared statement pooling to work.

This is the code I'm workign with:

       ConnectionFactory connFactory = new DriverManagerConnectionFactory(
               cfg.getUrl(),
               cfg.getUsername(),
               cfg.getPassword()
       );

ObjectPool connPool = new GenericObjectPool(null, cfg.toConfig());
KeyedObjectPoolFactory stmtPoolFactory = new GenericKeyedObjectPoolFactory(null);


       PoolableConnectionFactory x = new PoolableConnectionFactory(
               connFactory,
               connPool,
               stmtPoolFactory,
               cfg.getValidationQuery(),
               cfg.isDefaultReadOnly(),
               cfg.isDefaultAutoCommit(),
               cfg.getDefaultTransactionIsolation()
       );

       DataSource ds = new PoolingDataSource(connPool);

And when I run this, I'm getting an assertion failed when i retrieve two prepared statements for the same connection.

assertEquals(stmt, stmt2);
junit.framework.AssertionFailedError:
expected:<[EMAIL PROTECTED]>
but
was:<[EMAIL PROTECTED]>



assertEquals(((DelegatingPreparedStatement)stmt).getInnermostDelegate(),
((DelegatingPreparedStatement)stmt2).getInnermostDelegate());
junit.framework.AssertionFailedError:
expected:<[EMAIL PROTECTED]>
but was:<[EMAIL PROTECTED]>


What should I be expecting on this? How would I tell that the pooling is working correctly with PreparedStatements?
Can someone point out what I'm doing wrong above?


Thanks in advance
Ed Bridges






Reply via email to