Statement Caching in GlassFish V3
By shalini_m on Dec 17, 2009
In general, Statement Caching is a functionality of a jdbc driver. There do exist a few jdbc drivers that do not support caching of PreparedStatement, CallableStatement and Statement objects.
A new feature in GlassFish V3, Statement caching improves performance by searching for a match in the cache and returning the object instead of preparing the statement object every time. This is useful for applications that repeatedly execute the above type of statements. Pooling infrastructure in GlassFish V3 does what is depicted in the figure below.
GlassFish V3 uses a Least Recently Used (LRU) strategy for evicting statement objects from the cache. Every time a new statement is parsed and created, there is an overhead and to overcome this, set statement–cache–size attribute of jdbc connection pool to a non–zero value.
Effects of statement caching on pool
When Statement caching is set to a non-negative value, and Flush connection pool is executed, connections in the statement cache are recreated.