I am using BoneCP with MySQL in Java.
I have several threads, and overtime they will be requesting a connection from the pool to perform some query. The queries are repetitive so I'd like to use prepared statements.
I've used prepared statements before, when I only worked with one connection (and no pooling). But now that I have pooling, I'm not sure how's it done:
As far as I am concerned, a prepared statement is linked to a particular Connection
instance. If you return the connection to the pool, then the prepared statement is (or should be) destroyed. My threads only request a connection when they need to do a query - they return it after it is done so they don't retain any connection for a long time.
How do I use prepared statements along with connection pooling?