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.0
  • What is OceanBase Connector J?
    • JDBC overview
    • Compatibility requirements
  • Instructions
    • Install OceanBase Client
    • Basic operations
      • Import packages
      • Create a database connection
      • Create a Statement object
      • Run queries and retrieve ResultSet objects
      • Process a ResultSet object
      • Close ResultSet and Statement objects
      • Modify a database
      • Commit changes
      • Close a database connection
    • Handle SQL exceptions
    • 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 API
      • LOB locator API
      • CHAR, VARCHAR, and RAW data types
    • Use CallableStatements to call stored procedures
    • Data sources and URL
      • Data source overview
      • Data source characteristics and properties
      • Create and connect to a data source instance
      • Database URL
    • Result set
      • Limits and degradation rules
      • Fetch size
      • Refetch rows
      • Cursor result sets
    • Statement caching
      • Statement caching overview
      • Use statement cache
      • Reuse statement objects
    • Failover and load balancing modes
    • Batch processing
    • JDBC security features
    • Troubleshooting
    • 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
    • Call PL stored procedures
    • Result set performance
    • Create a multi-level collection type
    • 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.0

Download PDF

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

Overview of distributed transactions

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

XA data sources
XA connections
XA resources
Transaction IDs
OracleXAResource.ORATRANSLOOSE

When you use the XA feature, the transaction manager uses the XA resource instance to prepare and coordinate each transaction branch, and then properly commit or roll back all transaction branches.

Key components of the XA feature include XA data sources, XA connections, XA resources, and transaction IDs.

XA data sources

XA data sources are extensions of connection pool data sources and other data sources and are similar to those data sources in concept and functionality.

Each resource manager has an XA data source instance for distributed transactions. Typically, an XA data source instance is created in the intermediate-layer software.

XA data sources generate XA connections.

XA connections

XA connections are an extension of pooled connections and are similar to the latter in concept and functionality. XA connections are encapsulated with physical database connections. Each connection instance is a temporary handle of these physical connections.

An XA connection instance corresponds to only one session, although the session can be used by multiple logical connection instances in sequence, such as pooled connection instances.

Typically, you can obtain an XA connection instance from an XA data source instance in the intermediate-layer software. If a distributed transaction involves multiple sessions in the same database, it can get multiple XA connection instances from a single XA data source instance.

XA connections generate OracleXAResource instances and JDBC connection instances.

XA resources

The transaction manager uses XA resources to coordinate transaction branches for distributed transactions.

Typically, in the intermediate-layer software, you can obtain one OracleXAResource instance from each XA connection instance. OracleXAResource instances and XA connection instances are in one-to-one mapping. Similarly, OracleXAResource instances and sessions are in one-to-one mapping.

Typically, the intermediate-layer component hands over the OracleXAResource instances to the transaction manager for the coordination of distributed transactions.

Each OracleXAResource instance corresponds to one session, so the OracleXAResource instance is associated with only one active transaction branch at any given time, but may be associated with other suspended transaction branches.

Each OracleXAResource instance can process its associated session transaction branches, including starting, ending, preparing, committing, and rolling back the transaction branches.

The preparation step is the first step in a two-step commit operation. In this step, the transaction manager issues the PREPARE command to each OracleXAResource instance. When the transaction manager confirms that each transaction branch has been prepared for the operation, it issues the COMMIT command to each OracleXAResource instance to commit all changes.

Transaction IDs

A transaction ID is used to identify a transaction branch. Each transaction ID consists of a transaction branch ID component and a distributed transaction ID component. This is the way branches are associated with distributed transactions. All OracleXAResource instances associated with a given distributed transaction have transaction IDs that contain the same distributed transaction ID component.

OracleXAResource.ORATRANSLOOSE

Use the transaction ID xid to start a loosely coupled transaction.

Previous topic

Use ARRAY and STRUCT classes
Last

Next topic

XA components
Next
on this page
XA data sources
XA connections
XA resources
Transaction IDs
OracleXAResource.ORATRANSLOOSE