14-2 Oracle Fusion Middleware Configuring and Managing JDBC Data Sources for Oracle WebLogic Server
14.2 Managing the Statement Cache for a Data Source
For each connection in a data source in your system, WebLogic Server creates a statement cache. When a prepared statement or callable statement is used on a
connection, WebLogic Server caches the statement so that it can be reused. For more information about the statement cache, see
Section 10.1, Increasing Performance with the Statement Cache.
Each connection in the data source has its own statement cache, but configuration settings are made for all connections in the data source. You can clear the statement
cache for all connections in a data source using the Administration Console or you can programmatically clear the statement cache for an individual connection.
14.2.1 Clearing the Statement Cache for a Data Source
JDBCDataSourceRuntimeMBean.clearStatementCache You can manually clear the statement cache for all connections in a data source using
the Administration Console see Clear the statement cache in a JDBC data source or with the clearStatementCache method on the
JDBCDataSourceRuntimeMBean .
14.2.2 Clearing the Statement Cache for a Single Connection
weblogic.jdbc.extensions.WLConnection.clearStatementCache weblogic.jdbc.extensions.WLConnection.clearCallableStatementjava.lang.
String sql weblogic.jdbc.extensions.WLConnection.clearCallableStatementjava.lang.
String sql,int resType,int resConcurrency weblogic.jdbc.extensions.WLConnection.clearPreparedStatementjava.lang.
String sql weblogic.jdbc.extensions.WLConnection.clearPreparedStatementjava.lang.
String sql,int resType,int resConcurrency You can use methods in the weblogic.jdbc.extensions.WLConnection
interface to clear the statement cache for a single connection or to clear an individual statement from the cache. These methods return true if the operation was successful
and false if the operation fails because the statement was not found.
When prepared and callable statements are stored in the cache, they are stored keyed based on the exact SQL statement and result set parameters type and concurrency
options, if any. When clearing an individual prepared or callable statement, you must use the method that takes the proper result set parameters. For example, if you have
callable statement in the cache with resSetType of ResultSet.TYPE_SCROLL_ INSENSITIVE
and a resSetConcurrency of ResultSet.CONCUR_READ_ONLY, you must use the method that takes the result set parameters:
clearCallableStatementjava.lang.String sql,int resSetType,int resSetConcurrency If you use the method that only takes the SQL string as a parameter, the method will
not find the statement, nothing will be cleared from the cache, and the method will return false.
When you clear a statement that is currently in use by an application, WebLogic Server removes the statement from the cache, but does not close it. When you clear a
statement that is not currently in use, WebLogic Server removes the statement from the cache and closes it.
For more details about these methods, see the Javadoc for WLConnection.
Managing WebLogic JDBC Resources 14-3
14.3 Shrinking a Connection Pool