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.4.16

  • What is OceanBase Connector J?
    • Overview of OceanBase Connector/J
    • Compatibility requirements
  • Install Driver
    • Install and load OceanBase Connector/J
  • Instructions
    • Quick start
      • Import packages
      • Establish 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
      • Examples
    • Data sources and URL
      • Data source overview
      • Database URL
    • Java data streams
      • Overview of Java data streams
      • LONG and LONG RAW data types
      • Use LOBs
        • Overview of LOB data types
        • LOB data interface
        • LOB locator interface
      • CHAR, VARCHAR, and RAW data types
    • Statement caching
      • Overview of statement caching
      • Use statement caching
      • Reuse statement objects
    • Call a stored procedure
    • Handle SQL exceptions
    • Result set
      • Overview of result sets
      • Limitations
      • FetchSize
      • refreshRow
      • useCursorFetch
    • Batch processing
    • Failover and Load-Balancing
      • Failover and load balancing modes
      • LoadBalance strategies
      • Load balancing strategy configuration methods
    • Rich client
    • Logging
    • Network overheads
    • Show Trace
    • Security features
    • Troubleshooting
  • Reference
    • Features specific to the Oracle mode
      • Binary Protocol (Prepared Statements)
        • COM_STMT_PREPARE_EXECUTE
        • COM_STMT_SEND_PIECE_DATA
      • Call PL stored procedures
      • Scrollability of a result set
      • Use ARRAY and STRUCT classes
      • Distributed transactions
        • Overview
        • XA components
        • Distributed transaction examples
      • Obtain remarks
      • Data types supported in Oracle mode
      • Error messages in Oracle mode
    • Supported SQL and PL data types
    • Common APIs
      • Overview
      • 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
      • com.oceanbase.jdbc.ObPrepareStatement
  • Release Notes
    • V2.4
      • OceanBase Connector/J V2.4.16
      • OceanBase Connector/J V2.4.15
      • OceanBase Connector/J V2.4.14
      • OceanBase Connector/J V2.4.13
      • OceanBase Connector/J V2.4.12
      • OceanBase Connector/J V2.4.11
      • OceanBase Connector/J V2.4.8
      • OceanBase Connector/J V2.4.5
      • OceanBase Connector/J V2.4.4
      • OceanBase Connector/J V2.4.3
      • OceanBase Connector/J V2.4.2
      • OceanBase Connector/J V2.4.1
      • OceanBase Connector/J V2.4.0
    • 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

Overview of OceanBase Connector/J Compatibility requirements Install and load OceanBase Connector/J Import packages Establish 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 Examples Data source overview Database URL Overview of Java data streams LONG and LONG RAW data types CHAR, VARCHAR, and RAW data types Overview of statement caching Use statement caching Reuse statement objects Call a stored procedure Handle SQL exceptions Overview of result sets Limitations FetchSize refreshRow useCursorFetch Batch processing Failover and load balancing modes LoadBalance strategies Load balancing strategy configuration methods Rich client Logging Network overheads Show Trace Security features Troubleshooting Call PL stored procedures Scrollability of a result set Use ARRAY and STRUCT classes Obtain remarks Data types supported in Oracle mode Error messages in Oracle mode Supported SQL and PL data types Overview 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 com.oceanbase.jdbc.ObPrepareStatement OceanBase Connector/J V2.4.16 OceanBase Connector/J V2.4.15 OceanBase Connector/J V2.4.14 OceanBase Connector/J V2.4.13 OceanBase Connector/J V2.4.12 OceanBase Connector/J V2.4.11 OceanBase Connector/J V2.4.8 OceanBase Connector/J V2.4.5 OceanBase Connector/J V2.4.4 OceanBase Connector/J V2.4.3 OceanBase Connector/J V2.4.2 OceanBase Connector/J V2.4.1 OceanBase Connector/J V2.4.0 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
OceanBase logo

The Unified Distributed Database for the AI Era.

Follow Us
Products
OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
Resources
DocsBlogLive 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.4.16
iconOceanBase Connector/J
V 2.4.16
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

COM_STMT_PREPARE_EXECUTE

Last Updated:2026-05-08 09:36:35  Updated
Share
What is on this page
COM_STMT_PREPARE_EXECUTE protocol
COM_STMT_PREPARE_EXECUTE response
Client interaction process

folded

Share

In Oracle mode, OceanBase Connector/J supports the COM_STMT_PREPARE_EXECUTE protocol. This protocol allows you to send all the information contained in both the COM_STMT_PREPARE and COM_STMT_EXECUTE protocols in one go. It enables the execution of prepared statements and the handling of the corresponding results. This topic provides detailed information about the COM_STMT_PREPARE_EXECUTE protocol and the COM_STMT_PREPARE_EXECUTE response.

COM_STMT_PREPARE_EXECUTE protocol

The message content of the COM_STMT_PREPARE_EXECUTE protocol is as follows:

COM_STMT_PREPARE_EXECUTE
execute a prepared statement
direction: client -> server
response: COM_STMT_EXECUTE Response

payload:
     1                     [a1] COM_STMT_PREPARE_EXECUTE
     4                     statement-id
     1                     flags    
     4                     Iteration count 
     n                     query
     4                     num-params
         if num-params > 0:
     n                     NULL-bitmap, length: (num-params+7)/8
     1                     new-params-bound-flag
          if new-params-bound-flag == 1:
     n                      type of each parameter, length: num-params * 2
     n                      value of each parameter
     4                      execute_mode
     4                      num-close-stmt-count
          if num-close-stmt-count > 0 :
     4n                     num-close-stmt-count * close-stmt-id
     4                       check_sum
     4                       extend_flag

The following table describes the fields of the COM_STMT_PREPARE_EXECUTE protocol.

Length
Name
Description
1 [0xa1] Protocol number
4 stmt-id The ID of the prepared statement. The value is 0 for the first execution. If the stmt is executed repeatedly, the value is filled based on the value returned in the previous execution.
1 flags Cursor scrolling
4 iteration-count The value of the batch parameter of the same type. If the value is greater than 0, the server directly marks the has-result-set parameter. For INSERT, UPDATE, and DELETE operations, the default value is 1. For BATCH operations, the value is array_bounding when it is greater than 1. For SELECT operations, the value is the number of rows returned. If cursorFetch is used, the value is fetchSize. If no result set is returned, the value is set to 0.
n query The SQL statement.
4 num-params The number of parameters.
if num-params > 0 :
n null-bitmap The length is (num-params+7)/8. Each 8 parameters occupy 1 byte. The bit corresponding to a null value is 1.
1 new-params-bound-flag Indicates whether the subsequent execution continues to include types. If the value is 0, the stmt-id cannot be empty.
if new-params-bound-flag == 1 :
n type of each parameter The length is num-params*2.
n value of each parameter The values of all execution parameters.
4 execute_mode For more information, see OCIStmtExecute().
4 num-close-stmt-count The value is always 0.
if num-close-stmt-count > 0 :
4n num-close-stmt-count * close-stmt-id This parameter is not supported.
4 check_sum The sum check.
4 extend_flag A flag used for future extensions.

COM_STMT_PREPARE_EXECUTE response

The following table describes the fields of the COM_STMT_PREPARE_EXECUTE response.

| Length | Name | Description |

1 status [0x00] OK
4 stmt-id The ID of the prepared statement.
2 num-columns The number of columns in the table. This field is set to 0 for statements other than SELECT.
2 num-params The number of parameters in the SQL statement.
1 reserved-1 [00] filler
2 warning-count The number of warnings.
4 extend_flag The result set extension flag.
1 has-result-set Indicates whether a result set exists.
  • For INSERT, UPDATE, and DELETE operations, this field is set to False.
  • For SELECT operations, this field is set to False if the interate-count value is 0.
  • For call and anonymous block operations, this field is set to True if the operation has OUT parameters, and False otherwise.
if num-params > 0 :
n*m num-params * Protocol::ColumnDefinition The parameter definition block (Parameter Definition Block). This block must be returned for the first time, and can be omitted in subsequent responses.
EOF_Packet The parameter definition block (Parameter Definition Block). This block must be returned for the first time, and can be omitted in subsequent responses.
if num- colums > 0 :
n*m num-colums * Protocol::ColumnDefinition The column definition block (Column Definition Block). This block must be returned for the first time, and can be omitted in subsequent responses. The EOF packet and OK packet are compressed into the same protocol.
EOF_Packet [fe] The column definition block (Column Definition Block). This block must be returned for the first time, and can be omitted in subsequent responses. The EOF packet and OK packet are compressed into the same protocol.
if has-result-set :
n*m none or many ProtocolBinary::Resultset The result set.
EOF_Packet [fe] The EOF packet and the subsequent OK packet are separated. The EOF packet is also included in an empty result set.
if execute-success :
OK_Packet [00] For compatibility with the return operations of INSERT, UPDATE, and DELETE, an OK packet is always returned at the end of a successful operation.
if execute-failed :
ERR_Packet [ff] In OCI_EXACT_FETCH mode, the result set and error message are returned.

Client interaction process

The following code shows the client interaction process of the COM_STMT_PREPARE_EXECUTE protocol:

<<<<<<< llm_translation_of_commit_9fcedefd_260203102818

Connection conn = setConnection("&useOraclePrepareExecute=true");
pstmt = conn.prepareStatement("insert into test_set_params values(?,?,?)");   // No COM_STMT_PREPARE request is sent.
=======
Connection conn = setConnection("&useOraclePrepareExecute=true");
pstmt = conn.prepareStatement("insert into test_set_params values(?,?,?)");   // The COM_STMT_PREPARE request is not sent.
>>>>>>> V2.4.16
pstmt.setInt(1, 2);
pstmt.setString(2, "hijklmn");
pstmt.setTimestamp(3, Timestamp.valueOf(LocalDateTime.now()));
pstmt.executeUpdate();              // Sends a COM_STMT_PREPARE_EXECUTE request.

Previous topic

Troubleshooting
Last

Next topic

COM_STMT_SEND_PIECE_DATA
Next
What is on this page
COM_STMT_PREPARE_EXECUTE protocol
COM_STMT_PREPARE_EXECUTE response
Client interaction process