I rewrote the statement caching in Minerva for a number
of reasons:( tar attached)
- Make the allowable open statements configurable from
- Consolidate statement caching logic into one class
for less code duplication
- To be able to keep track of all open statements a
connection has so that we release prepared statements
when a maximum of allowed open statements(plain
Statements plus PreparedStatements) is reached.
What did I change?
- You can configure the maximum allowable open
statements by putting in a property in the Properties
tag in the XADataSourceLoader xml stuff in jboss.jcml
"-1" value means caching is turned off
"0" value means caching is unlimited
- org.opentools.minerva.jdbc.StatementFactory contains
all the logic for statement creation and caching.
Prepared statements only are cached, but all open
statements are counted. If a createStatement will put
the open statements over MaxOpenStatements, then a
prepared statement will be closed and released from the
- ConnectionInPool and XAClientConnection delegate to a
StatementFactory for creating, preparing and closing
- there is no longer a psCaches HashMap contained in
ConnectionInPool as a static variable. This is instead
renamed to sfCaches and hold a hashmap of connections
- XADataSourceImpl reads the properties and extracts
MaxOpenStatements. I also remove MaxOpenStatements
from the Properties so that the JDBC driver doesn't get
screwed up by a property it doesn't understand.
Tell me what you think, and if you need more
information please let me know. I have tested the code
with caching turned on and off and unlimited and it
seems to work pretty good with the application we're
writing to JBoss. Let me know if you think these
changes are relevant.