OceanBase logo

OceanBase

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

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

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

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

  • 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
      • clientInfoProvider
    • 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.17
      • 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 URLclientInfoProvider 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.17 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 & Certification
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.17
iconOceanBase Connector/J
V 2.4.17
  • 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-04-10 06:56: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, and can issue all information contained in COM_STMT_PREPARE and COM_STMT_EXECUTE at a time, execute prepared statements, and process the corresponding results. This topic describes the COM_STMT_PREPARE_EXECUTE protocol and COM_STMT_PREPARE_EXECUTE RESPONSE.

COM_STMT_PREPARE_EXECUTE protocol

The packet of the COM_STMT_PREPARE_EXECUTE protocol contains the following content:

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 Field Description
1 [0xa1] The protocol number.
4 stmt-id The ID of the prepared statement. 0 is sent for the first time. Each subsequent execution of the statement increments the value by 1, based on the last return value.
1 flags The cursor scrollability.
4 iteration-count batch parameters of the same type are supported. When the value is greater than 0, the server directly tags has-result-set. The default value is 1 for INSERT, UPDATE, and DELETE operations. When the value is greater than 1, BATCH operations are array_binding. For SELECT operations, the number of rows is returned. If cursorFetch is used, the value is the value of fetchSize. To return no result set, set the value 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. Specifically, every eight parameters occupy one byte and the bit corresponding to the null value is 1.
1 new-params-bound-flag Specifies whether to include the type in subsequent executions. If the value is set to 0, stmt-id must be specified.
if new-params-bound-flag == 1 :
n type of each parameter The length is num-params*2.
n value of each parameter The value of each execution parameter.
4 execute_mode For more information, see OCIStmtExecute().
4 num-close-stmt-count The value is fixed to 0.
if num-close-stmt-count > 0 :
4n num-close-stmt-count * close-stmt-id This field is not supported.
4 check_sum The checksum.
4 extend_flag The reserved extension flag.

COM_STMT_PREPARE_EXECUTE RESPONSE

The following table describes the fields of COM_STMT_PREPARE_EXECUTE RESPONSE.

Length Field Description
1 status [0x00] OK
4 stmt-id The ID of the prepared statement.
2 num-columns The number of columns in the table. The value is 0 for a non-SELECT statement.
2 num-params The number of SQL statement parameters.
1 reserved-1 [00] filler
2 warning-count The number of warnings.
4 extend_flag The result set extension flag.
1 has-result-set Specifies whether a result set is available.
  • For INSERT, UPDATE, and DELETE operations, False is returned.
  • For SELECT operations, if iteration-count is 0, False is returned.
  • For stored procedure calls and anonymous blocks, if an OUT parameter is present, True is returned; otherwise, False is returned.
if num-params > 0 :
n*m num-params * Protocol::ColumnDefinition The parameter definition block. This field must be returned for the first EXECUTE operation on a prepared statement and can be omitted for subsequent requests.
EOF_Packet The parameter definition block. This field must be returned for the first EXECUTE operation on a prepared statement and can be omitted for subsequent requests.
if num- colums > 0 :
n*m num-colums * Protocol::ColumnDefinition The column definition block. This field must be returned for the first EXECUTE operation on a prepared statement and can be omitted for subsequent requests. The EOF_Packet and OK_Packet packets are compressed in the same protocol.
EOF_Packet [fe] The column definition block. This field must be returned for the first EXECUTE operation on a prepared statement and can be omitted for subsequent requests. The EOF_Packet and OK_Packet packets are compressed in the same protocol.
if has-result-set :
n*m none or many ProtocolBinary::Resultset The result set.
EOF_Packet [fe] The EOF_Packet packet is separated from the OK_Packet packet, and is also contained in an empty result set.
if execute-success :
OK_Packet [00] To adapt to the return operations of INSERT, UPDATE, and DELETE, the result set must end with an OK_Packet packet if the operation is successful.
if execute-failed :
ERR_Packet [ff] In OCI_EXACT_FETCH mode, the result set and error message are returned.

Client interaction process

The client interaction code of the COM_STMT_PREPARE_EXECUTE protocol is as follows:

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

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