File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and the fly likes PreparedStmt Cache ... ResultSets? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "PreparedStmt Cache ... ResultSets?" Watch "PreparedStmt Cache ... ResultSets?" New topic

PreparedStmt Cache ... ResultSets?

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
We have a new tool on our QA servers (EJB with UDB) that tells us the number of instances of various classes at any point in time. One of the guys monitored PreparedStatements and saw the number go up and down over time and then settle down at 16 when the test was idle. PS are cached on a per-connection basis; does this stable 16 sound like that cache? Guess I should look up the connection pool minimum size and see what it is.

At the same point in time he found 17 ResultSet objects. Would they be attached to cached PreparedStatements or cached for some other reason? Did we fail to close them or something silly? Or maybe a plain old memory leak?

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Are you executing a stored procedure which is returning multiple ResultSets?

SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Nope, just queries, most generated by a data mapping tool, some written by hand. Even with the hand-thrown SQL we go through generated DAOs to execute, so things like handling exceptions and closing connections is consistent - whether it's correct or not remains to be seen.
I agree. Here's the link:
subject: PreparedStmt Cache ... ResultSets?
Similar Threads
Pooling Prepared Statements
Why we can't share PreparedStatement cache across connections
Issue with JPS and refreshing Entity bean's data.
Locating a DNS server
Connection pooling Examples