JDBC enables or disables statement cache and sets the number of callable statements and the maximum number of cached SQL statements through API operations.
The following table describes the parameters.
| Parameter | Description |
|---|---|
| useServerPrepStmts | Specifies whether to prepare statements on the server before execution. The applications that repeatedly use the same queries have a value to activate this option, but the general practice is to use the direct command (text protocol). If rewriteBatchedStatements is true, this parameter is set to false. Default value: false. |
| cachePrepStmts | Specifies whether to cache the prepared statements. If useServerPrepStmts = true, commands that are composed of the prepared statements are cached in the LRU cache to avoid re-preparing the commands. The next time you execute a prepared statement that is cached in the LRU cache, the prepared identifiers and parameters, if any, will be sent to the server. This option prevents the server from re-parsing the statement. Default value: true. |
| prepStmtCacheSize | The maximum number of statements that can be cached. When useServerPrepStmts = true, you can set this parameter to specify the maximum number of prepared statements that can be cached. Default value: 250. |
| prepStmtCacheSqlLimit | The maximum length of a prepared statement that can be cached (in bytes). If useServerPrepStmts = true, prepared statements with a length greater than this threshold will not be cached. Default value: 2048. |
| cacheCallableStmts | Specifies whether to enable caching callable statements. Default value: true. |
| callableStmtCacheSize | Specifies the maximum number of callable statements that can be cached. If cacheCallableStmts is set to true, you can set this parameter to specify the maximum number of callable statements that the driver can cache for each VM. Default value: 150. |