I _did_ try Google, I promise. There are a few examples of this, but
they're not documented enough that I fully understand proper use of this...
It appears that I can enable pooling of preparedStatements by "simply"
including an ObjectPoolFactory in the PoolableConnectionFactory constructor:
KeyedObjectPoolFactory stmtPoolFactory = new
GenericKeyedObjectPoolFactory(null);
new PoolableConnectionFactory(connectionFactory, connectionPool,
stmtPoolFactory, null, false, true,
Connection.TRANSACTION_READ_COMMITTED);
(I suppose the first question is please confirm that is all I need to do
for initial-setup?)
But how do I add & retrieve preparedStatements to/from the pool?
Should my method always call conn.prepareStatement("update..."); and in
the background if a previously-prepared statement is available, it'll be
used otherwise it's sent to the DB as normal? Do I just "close" the
prepared statement normally, and again, the prepared statement will be
returned (or added) to the pool automatically?
When managing my own jdbc connection, I would typically prepare the
statements once, in some kind of init method and tuck them away in a
private variable, so they were available throughout the remainder of the
class/program's lifetime. Calling conn.prepareStatement( ) every time I
want to [re-]use a statement just feels counter-intuitive somehow.
Thanks for bearing-with my newbie questions.
-AJ
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]