OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Connector/J

V2.2.7

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogWhite PaperLive DemosTraining & CertificationTicket
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Connector/J
    3. V2.2.7
    iconOceanBase Connector/J
    V 2.2.7
    Databases
    • OceanBase Database
    • OceanBase Cloud
    • OceanBase Tugraph
    • Interactive Tutorials
    • OceanBase Best Practices
    Tools
    • OceanBase Cloud Platform
    • OceanBase Migration Service
    • OceanBase Developer Center
    • OceanBase Migration Assessment
    • OceanBase Admin Tool
    • OceanBase Loader and Dumper
    • OceanBase Deployer
    • Kubernetes operator for OceanBase
    • OceanBase Diagnostic Tool
    • OceanBase Binlog Service
    Connectors and Middleware
    • OceanBase Database Proxy
    • Embedded SQL in C for OceanBase
    • OceanBase Call Interface
    • OceanBase Connector/C
    • OceanBase Connector/J
    • OceanBase Connector/ODBC
    • OceanBase Connector/NET
    • V 2.4.18
    • V 2.4.17
    • V 2.4.16
    • V 2.4.15
    • V 2.4.14
    • V 2.4.5
    • V 2.4.4
    • V 2.4.3
    • V 2.4.2
    • V 2.4.1
    • V 2.4.0
    • V 2.2.11
    • V 2.2.10
    • V 2.2.7
    • V 2.2.6
    • V 2.2.3
    • V 2.2.0

    Reuse statement objects

    Last Updated:2026-04-09 07:31:40  Updated
    Share
    What is on this page
    Use pooled statements
    Disable pooled statements

    folded

    Share

    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
    What is on this page
    Use pooled statements
    Disable pooled statements