|
| Problem | PreparedStatement Cache | | | | Solution | What is a PreparedStatement?A PreparedStatement is an object that represents a pre-compiled SQL statement. A SQL statement is pre-compiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times.
PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEE SET SALARY = ? WHERE ID = ?"); pstmt.setBigDecimal(1, 55000.00) pstmt.setInt(2, 1234567)
Note: The setXXX methods for setting IN parameter values must specify types that are compatible with the defined SQL type of the input parameter. For instance, if the IN parameter has SQL type Integer, then the method setInt should be used. What is PreparedStatement Cache?The WebSphere® Application Server data source optimizes processing of prepared statements. It manages a pool of database connections, as well as an associated cache of prepared statement objects. Prepared statements are cached separately for each connection that executes them. What is the Default Value for PreparedStatement Cache?The default value for Prepared Statement Cache size is 100.How to Set the PreparedStatement Cache Size?The Prepared Statement Cache size is specified through the Data Source object by way of file datasources.xml which is placed in the install_root/properties and then restarting WebSphere Application Server (where install_root is the directory where WebSphere Application Server is installed, for example, C:\WebSphere\AppServer on Windows® NT or Windows 2000).A sample datasources.xml file specifying a cache size of 500 for data source Sample follows:
<data-sources> <data-source name="Sample"> <attribute name="statementCacheSize" value="500"/> </data-source> </data-sources>
How to Disable PreparedStatement Cache?To disable Prepared Statement cache, set the value of "statementCacheSize" for the data source to 0 ("zero").Note: In order to disable the PreparedStatement Cache, you must apply the latest WebSphere Application Server connection manager cumulative fix, listed in Recommended Updates | |
| |
| |
|
Product categories: Software, Application Servers, Distributed Application & Web Servers, WebSphere Application Server, Java 2 Connectivity (J2C) Operating system(s): AIX, HPUX, Linux, Multi-Platform, Solaris, Windows Software version: 3.5.2, 3.5.3, 3.5.4 Software edition: Advanced, Standard Reference #: 1051635 IBM Group: Software Group Modified date: 2004-12-16
(C) Copyright IBM Corporation 2000, 2004. All Rights Reserved.
|