View RSS Feed


J2EE PreparedStatement Cache

Rate this Entry
by , 04-27-2012 at 08:10 PM (1496 Views)
J2EE PreparedStatement Cache is implemented using a cache inside the J2EE server connection pool manager. The J2EE server keeps a list of prepared statements for each database connection in the pool. When an application calls prepareStatement on a connection, the application server checks if that statement was previously prepared. If it was, the PreparedStatement object will be in the cache and this will be returned to the application. If not, the call is passed to the jdbc driver and the query/preparedstatement object is added in that connections cache.

We need a cache per connection because that's the way jdbc drivers work. Any preparedstatements returned are specific to that connection.

If we want to take advantage of this cache, the same rules apply as before. We need to use parameterized queries so that they will match ones already prepared in the cache. Most application servers will allow you to tune the size of this prepared statement cache.

Submit "J2EE PreparedStatement Cache" to Facebook Submit "J2EE PreparedStatement Cache" to Digg Submit "J2EE PreparedStatement Cache" to Submit "J2EE PreparedStatement Cache" to StumbleUpon Submit "J2EE PreparedStatement Cache" to Google