OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

OceanBase Connector/J

V2.2.7
  • What's New
  • What is OceanBase Connector J?
    • Overview of OceanBase Connector/J
    • Compatibility requirements
  • Instructions
    • Install and load the OceanBase Connector/J driver
    • Connect Python applications to OceanBase Database
    • Basic operations
      • Import packages
      • Create a database connection
      • Create a Statement object
      • Run queries and retrieve ResultSet objects
      • Process ResultSet objects
      • Close ResultSet and Statement objects
      • Manage tables and data
      • Commit changes
      • Close a database connection
      • Example
    • Handle SQL exceptions
    • Use CallableStatements to call stored procedures
    • Java data streams
      • Overview of Java data streams
      • LONG and LONG RAW data types
      • LOB data types
    • Use LOBs
      • Overview of LOB data types
      • LOB data interface
      • LOB locator API
      • CHAR, VARCHAR, and RAW data types
    • Data sources and URL
      • Data source overview
      • Data source characteristics and properties
      • Create and connect to a data source instance
      • Database URL
    • Result set
      • Overview of result sets
      • Limits
      • FetchSize
      • refreshRow
      • useCursorFetch
    • Statement caching
      • Overview of statement caching
      • Use statement caching
      • Reuse statement objects
    • Failover and load balancing modes
    • Batch processing
    • Security features
    • SQL NetworkCostInfo
    • Troubleshooting
    • Common APIs
      • Overview of common APIs
      • java.sql.Connection
      • java.sql.CallableStatement
      • java.sql.DatabaseMetaData
      • java.sql.Driver
      • java.sql.PreparedStatement
      • java.sql.ParameterMetaData
      • java.sql.ResultSet
      • java.sql.ResultSetMetaData
      • java.sql.Statement
      • javax.sql.ConnectionPoolDataSource
      • javax.naming.Context
      • javax.sql.PooledConnection
    • Reference
      • Supported SQL and PL data types
  • Features specific to the Oracle mode
    • Binary Protocol (Prepared Statements)
      • COM_STMT_PREPARE_EXECUTE
      • COM_STMT_SEND_PIECE_DATA
    • Call PL stored procedures
    • Result set performance
    • Use ARRAY and STRUCT classes
    • Distributed transactions
      • Overview of distributed transactions
      • XA components
      • Distributed transaction examples
    • Error messages in Oracle mode
    • Data types supported in Oracle mode
  • Release Notes
    • V2.2
      • OceanBase Connector/J V2.2.11
      • OceanBase Connector/J V2.2.10
      • OceanBase Connector/J V2.2.7
      • OceanBase Connector/J V2.2.6
      • OceanBase Connector/J V2.2.3
      • OceanBase Connector/J V2.2.0

Download PDF

Document Feedback
  1. Documentation Center
  2. OceanBase Connector/J
  3. V2.2.7

Reuse statement objects

Last Updated:2026-09-04 08:24:25

Use pooled statements
Disable pooled statements

The Pooled Statement feature of OceanBase Connector/J allows applications to reuse PreparedStatement objects in the same way as using Connection objects.

Multiple logical connections can reuse PreparedStatement objects in a transparent manner.

Use pooled statements

An application can call the isPoolable method from the Statement API to check whether the data source supports pooled statements. If true is returned, the application learns that PreparedStatement objects are under preparation. The application can also call the setPoolable method from the Statement API to request statements to be or not to be pooled.

Reusing of a pooled statement must be completely transparent to the application. In other words, regardless of whether the PreparedStatement objects participate in statement pooling, the application code remains the same. If the application disables thePreparedStatement objects, you can call the Connection.prepareStatement method to reuse them.

Disable pooled statements

An application can disable pooled statements and non-pooled statements in the same way. If a statement is disabled, it is no longer available for the application, regardless of whether it has been pooled or not. An error will occur if you attempt to reuse the statement. The only difference between disabling a pooled statement and a non-pooled statement lies in that the application cannot directly close a physical statement that is being pooled, which can be closed only by the pool manager. The PooledConnection.closeAll method closes all statements that run on a given physical connection to release the resources associated with the statements.

You can close a pooled statement by using the following methods:

  • close

    This java.sql.Statement API can be called by an application. If the statement is being pooled, this method closes the logical statement used by the application, but not the physical statement that is being pooled.

  • close

    This java.sql.Connection API can be called by an application. The behavior of this method varies depending on whether the connection using the statement is pooled.

    • Nonpooled connection

      This method closes the physical connection and all statements created by the connection. This is necessary because the garbage collection mechanism cannot detect when externally managed resources can be released.

    • Pooled connection

      This method closes the logical connection and the logical statements it returned, but opens the underlying PooledConnection object and all associated cache statements.

  • PooledConnection.closeAll

    The connection pool manager calls this method to close all physical statements that are being pooled for thePooledConnection object.

Previous topic

Use statement caching
Last

Next topic

Failover and load balancing modes
Next
on this page
Use pooled statements
Disable pooled statements