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 Cloud

  • Product Updates & Announcements
    • What's new
      • Release notes for 2026
      • Release notes for 2025
      • Release notes for 2024
      • Release history
    • Product announcements
      • Data development module deprecation notice
      • Optimization of Backup and Restore commercialization strategy
      • Cross-AZ data transfer billing (OceanBase Cloud on AWS)
      • Database Proxy pricing update
      • AWS instance pricing adjustment
  • Product Introduction
    • Overview
    • Management mode and scenarios
    • Core features
      • High availability with cross-cloud active-active architecture
      • High availability with cross-cloud primary-standby databases
      • Multi-level caching in shared storage
      • Multi-layer online scaling and on-demand adjustment
    • Deployment modes
    • Storage architecture
    • Product specifications
    • Product billing
      • Overview
      • Instance billing
        • Tencent Cloud instance billing
        • Alibaba Cloud instance billing
        • Huawei Cloud instance billing
        • AWS instance billing
        • GCP instance billing
      • Backup and restore billing
      • SQL audit billing
      • Migrations billing
      • Database proxy billing
      • Binlog service billing
      • Overview of OceanBase Cloud support plans
      • Read-only replica billing
    • Supported database versions
  • Get Started
    • Get started with a transactional instance
    • Get started with an analytical instance
    • Get started with a Key-Value instance
  • Work with Transactional Instances
    • Overview
    • Create an instance
      • Overview
      • Create via OceanBase Cloud official website
      • Create via AWS Marketplace
      • Create via GCP Marketplace
      • Create via Huawei Cloud Marketplace
      • Create via Alibaba Cloud Marketplace
      • Create via Azure Marketplace
    • Connect to an instance
      • MySQL compatible mode
        • Overview
        • Get connection string
          • Overview
          • Connect using AWS PrivateLink
          • Connect using Azure Private Link
          • Connect using Google Cloud Private Service Connect
          • Connect using Huawei Cloud VPC Endpoint
          • Connect using Alibaba Cloud VPC
          • Connect using a public IP address
          • Connect using a Huawei Cloud peering connection
        • Connect with clients
          • Connect to OceanBase Cloud by using Client ODC
          • Connect to OceanBase Cloud by using a MySQL client
          • Connect to OceanBase Cloud by using OBClient
        • Connect with drivers
          • Java
            • Connect to OceanBase Cloud using SpringBoot
            • SpringBatch sample application for connecting to OceanBase Cloud
            • spring-jdbc
            • SpringDataJPA sample application for connecting to OceanBase Cloud
            • Hibernate application development with OceanBase Cloud
            • Sample program for connecting to OceanBase Cloud
            • connector-j
            • Use TestContainers to connect to and use OceanBase Cloud
          • Python
            • Connect to OceanBase Cloud using mysqlclient
            • Connect to OceanBase Cloud using PyMySQL
            • Use the MySQL-connector-python driver to connect to and use OceanBase Cloud
            • Use SQLAlchemy to connect to an OceanBase Cloud database
            • Connect to an OceanBase Cloud database using Django
            • Connect to an OceanBase Cloud database by using peewee
          • C
            • Use MySQL Connector/C to connect to OceanBase Cloud
          • Go
            • Connect to OceanBase Cloud using the Go-SQL-Driver/MySQL driver
            • Connect to OceanBase Cloud using GORM
          • PHP
            • Use the EXT driver to connect to OceanBase Cloud
            • Connect to OceanBase Cloud by using the MySQLi driver
            • Use the PDO driver to connect to OceanBase Cloud
          • Rust
            • Rust application example for connecting to OceanBase Cloud
            • SeaORM example for connecting to OceanBase Cloud
          • ruby
            • ActiveRecord sample application for OceanBase Cloud
            • Connect to OceanBase Cloud by using mysql2
            • Connect to OceanBase Cloud by using Sequel
        • Use database connection pool
          • Database connection pool configuration
          • Connect to OceanBase Cloud by using a Tomcat connection pool
          • Connect to OceanBase Cloud by using a C3P0 connection pool
          • Connect to OceanBase Cloud by using a Proxool connection pool
          • Connect to OceanBase Cloud by using a HikariCP connection pool
          • Connect to OceanBase Cloud by using a DBCP connection pool
          • Connect to OceanBase Cloud by using Commons Pool
          • Connect to OceanBase Cloud by using a Druid connection pool
      • Oracle compatible mode
        • Overview
        • Get connection string
          • Overview
          • Connect using AWS PrivateLink
          • Connect using Azure Private Link
          • Connect using Google Cloud Private Service Connect
          • Connect using Huawei Cloud VPC Endpoint
          • Connect using a public IP address
        • Connect with clients
          • Connect to OceanBase Cloud by using OBClient
          • Connect to OceanBase Cloud by using Client ODC
        • Connect with drivers
          • Java
            • Connect to OceanBase Cloud using OceanBase Connector/J
            • Connect to OceanBase Cloud by using Spring Boot
            • SpringBatch application example for connecting to OceanBase Cloud
            • Connect to OceanBase Cloud using Spring JDBC
            • Connect to OceanBase Cloud by using Spring Data JPA
            • Connect to OceanBase Cloud by using Hibernate
            • Use MyBatis to connect to OceanBase Cloud
            • Use JFinal to connect to OceanBase Cloud
          • Python
            • Python Driver for Oracle Mode
          • C
            • Connect to OceanBase Cloud using OceanBase Connector/C
            • Connect to OceanBase Cloud using OceanBase Connector/ODBC
            • Use SqlSugar to connect to OceanBase Cloud
        • Use database connection pool
          • Database connection pool configuration
          • Sample program that uses a Tomcat connection pool to connect to OceanBase Cloud
          • C3P0 connection pool connects to OceanBase Cloud
          • Connect to OceanBase Cloud using Proxool connection pool
          • Sample program that uses HikariCP to connect to OceanBase Cloud
          • Use DBCP connection pool to connect to OceanBase Cloud
          • Connect to OceanBase Cloud by using Commons Pool
          • Connect to OceanBase Cloud by using a Druid connection pool
    • Developer guide
      • MySQL compatible mode
        • Plan database objects
          • Create a database
          • Create a table group
          • Create a table
          • Create an index
          • Create an external table
        • Write data
          • Insert data
          • Update data
          • Delete data
          • Replace data
          • Generate test data in batches
        • Read data
          • Single-table queries
          • Join tables
            • INNER JOIN queries
            • FULL JOIN queries
            • LEFT JOIN queries
            • RIGHT JOIN queries
            • Subqueries
            • Lateral derived tables
          • Use operators and functions in queries
            • Use arithmetic operators in queries
            • Use numerical functions in queries
            • Use string concatenation operators in queries
            • Use string functions in queries
            • Use datetime functions in queries
            • Use type conversion functions in queries
            • Use aggregate functions in queries
            • Use NULL-related functions in queries
            • Use the CASE conditional operator in queries
            • Use the SELECT ... FOR UPDATE statement to lock query results
            • Use the SELECT ... LOCK IN SHARE MODE statement to lock query results
          • Use a DBLink in queries
          • Set operations
        • Manage transactions
          • Overview
          • Start a transaction
          • Savepoints
            • Mark a savepoint
            • Roll back a transaction to a savepoint
            • Release a savepoint
          • Commit a transaction
          • Roll back a transaction
      • Oracle compatible mode
        • Plan database objects
          • Create a table group
          • Create a table
          • Create an index
          • Create an external table
        • Write data
          • Insert data
          • Update data
          • Delete data
          • Replace data
          • Generate test data in batches
        • Read data
          • Single-table queries
          • Join tables
            • INNER JOIN queries
            • FULL JOIN queries
            • LEFT JOIN queries
            • RIGHT JOIN queries
            • Subqueries
            • Lateral derived tables
          • Use operators and functions in queries
            • Use arithmetic operators in queries
            • Use numerical functions in queries
            • Use string concatenation operators in queries
            • Use string functions in queries
            • Use datetime functions in queries
            • Use type conversion functions in queries
            • Use aggregate functions in queries
            • Use NULL-related functions in queries
            • Use CASE functions in queries
            • Use the SELECT ... FOR UPDATE statement to lock query results
          • Use a DBLink in queries
          • Set operations
        • Manage transactions
          • Overview
          • Start a transaction
          • Savepoints
            • Mark a savepoint
            • Roll back a transaction to a savepoint
          • Commit a transaction
          • Roll back a transaction
    • Manage instances
      • Manage instances
        • View the instance list
        • Instance overview
        • Stop and restart instances
        • Unit migration
      • Manage tenants
        • Tenant overview
        • Create a tenant
        • Modify tenant specifications
        • Modify tenant names
        • Add an endpoint
        • Resource isolation
          • Overview
          • Manage resource groups
            • Create a resource group
            • View a resource group
            • Edit a resource group
            • Delete a resource group
          • Manage isolation rules
            • Create an isolation rule
            • View isolation rules
            • Edit an isolation rule
            • Delete a quarantine rule
        • Modify primary zone
        • Modify the maximum number of connections for a tenant proxy
        • Monitor tenant performance
          • Overview
          • View performance and SQL monitoring details
          • View transaction monitoring details
          • View storage and cache monitoring details
          • View Binlog service monitoring
          • Customize a monitoring dashboard for a tenant
        • Diagnostics
          • Real-time diagnostics
            • SQL diagnostics
              • Top SQL
              • Slow SQL
              • Suspicious SQL
              • High-risk SQL
            • SQL audit
        • Manage tenant parameters
          • Manage tenant parameters
          • Parameters for tenants
          • Parameter template overview
        • Delete a tenant
        • Manage databases and accounts
          • Create accounts
          • Manage accounts
          • Create a database (MySQL compatible mode)
          • Manage databases (MySQL compatible mode)
      • Monitor instance performance
        • Overview
        • Monitor the performance of databases in an instance
        • Monitor multidimensional metrics of an instance
        • Monitor the performance of hosts in an instance
        • Monitor database proxy
        • Monitor database proxy hosts
        • Monitor cross-cloud network performance
        • Customize a monitoring dashboard for an instance
      • Manage major compactions
        • Initiate a major compaction
        • View compaction records
        • Update time for compactions
      • Manage instance parameters
        • Manage parameters
        • Parameters for cluster instances
      • Change instance configurations
        • Enable storage auto-scaling
        • View history of configuration changes
        • Change configuration
        • Change configuration temporarily
        • Switch the deployment mode
      • Manage standby instances
        • Overview
        • Create a standby instance
        • Create a cross-cloud standby instance
        • Create a standby instance for an Alibaba Cloud primary instance
        • View details of primary and standby instances
        • Configure global endpoint
        • Enable automatic forwarding for write requests of standby databases
        • Primary-standby instance switchover
        • Initiate failover
        • Detach a standby instance
        • Release a standby instance
      • Release an instance
      • Database proxy
        • Overview
        • Manage database proxy
        • Direct load
      • Manage alerts
        • Overview
        • Manage alert rules
          • Create an alert rule
          • View an alert rule
          • Edit an alert rule
          • Delete an alert rule
        • View alert history
        • Manage alert templates
          • Create an alert template
          • View an alert template
          • Edit an alert template
          • Copy an alert rule template
          • Delete an alert template
        • Manage muting rules
          • Create an alert muting rule
          • View an alert muting rule
          • Edit an alert muting rule
          • Delete an alert muting rule
        • Manage alert notification templates
          • Create an alert notification template
          • View an alert notification template
          • Edit an alert notification template
          • Copy an alert notification template
          • Delete an alert notification template
        • Manage alert contacts
          • Add an alert contact
          • Add an alert contact group
          • View an alert contact
          • Edit an alert contact
          • Delete an alert contact
          • Obtain a webhook URL
        • Monitoring metrics for alerts
      • Backup and restore
        • Overview
        • Backup strategy
        • Initiate a backup immediately
        • Data backup
        • Initiate a restore
        • Data restore
        • Restore data from the instance recycle bin
      • Diagnostics
        • View performance monitoring data
        • Capacity diagnostics
        • One-click diagnostics
          • Initiate one-click diagnostics
          • View one-click diagnostic report
            • Exceptions
            • Real-time diagnostics
            • Optimization suggestions
            • Capacity management
            • Security management
        • Real-time diagnostics
          • SQL diagnostics
            • Top SQL
            • Slow SQL
            • Suspicious SQL
            • High-risk SQL
            • SQL details
            • SQL monitoring metrics list
          • Session management
            • Session management
          • Request analysis
            • Request analysis
        • Root cause diagnostics
          • Exception handling
          • Enable system autonomy
        • SQL audit
        • Materialized view analysis
        • Optimization center
          • Optimization suggestions
          • Manage active outlines
          • SQL review
          • View the optimization history
      • Manage tags
      • Manage read-only replicas
        • Overview
        • Instance read-only replicas
          • Add a read-only replica to an instance
          • View read-only replicas of an instance
          • Manage read-only replicas of an instance
          • Delete a read-only replica of an instance
        • Tenant read-only replicas
          • Add a read-only replica to a tenant
          • View read-only replicas of a tenant
          • Manage read-only replicas of a tenant
          • Delete a read-only replica of a tenant
      • Manage JVM-dependent services
    • Data source management
      • Create a data source
      • Manage data sources
      • User privileges
        • User privileges for compatibility assessment
        • User privileges for data migration
        • User privileges for performance assessment
        • User privileges for data archiving
        • User privileges for data cleanup
      • Connect via private network
        • AWS
        • Huawei Cloud
        • Alibaba Cloud
        • Google Cloud
        • Azure
        • Private IP address segments
      • Connect via public network
        • AWS
        • Huawei Cloud
        • Alibaba Cloud
        • Google Cloud
        • Azure
    • Data lifecycle management
      • Archive data
      • Clean up data
    • Manage recycle Bin
      • Instance recycle bin
      • Manage databases and tables in recycle bin
        • Overview
        • Instance-level recycle bin
        • Tenant-level recycle bin
  • Work with Analytical Instances
    • Overview
    • Core features
    • Create an instance
    • Connect to an instance
      • Overview
      • Get connection string
        • Overview
        • Connect using AWS PrivateLink
        • Connect using a public IP address
      • Connect with clients
        • Connect to OceanBase Cloud by using Client ODC
        • Connect to OceanBase Cloud by using a MySQL client
        • Connect to OceanBase Cloud by using OBClient
      • Connect with drivers
        • Java
          • Connect to OceanBase Cloud by using Spring Boot
          • Connect to OceanBase Cloud by using Spring Batch
          • Connect to OceanBase Cloud by using Spring Data JDBC
          • Connect to OceanBase Cloud by using Spring Data JPA
          • Connect to OceanBase Cloud by using Hibernate
          • Connect to OceanBase Cloud by using MyBatis
          • Connect to OceanBase Cloud using MySQL Connector/J
        • Python
          • Connect to OceanBase Cloud by using mysqlclient
          • Connect to OceanBase Cloud by using PyMySQL
          • Connect to OceanBase Cloud using MySQL Connector/Python
        • C
          • Connect to OceanBase Cloud using MySQL Connector/C
        • Go
          • Connect to OceanBase Cloud using Go-SQL-Driver/MySQL
        • PHP
          • Connect to OceanBase Cloud using PHP
      • Use database connection pool
        • Database connection pool configuration
        • Connect to OceanBase Cloud by using a Tomcat connection pool
        • Connect to OceanBase Cloud by using a C3P0 connection pool
        • Connect to OceanBase Cloud by using a Proxool connection pool
        • Connect to OceanBase Cloud by using a HikariCP connection pool
        • Connect to OceanBase Cloud by using a DBCP connection pool
        • Connect to OceanBase Cloud by using Commons Pool
        • Connect to OceanBase Cloud by using a Druid connection pool
    • Data table design
      • Table overview
      • Best practices
        • Unit 1: Best practices for optimizing storage structures and query performance
        • Unit 2: Best practices for creating special indexes
    • Export data
    • OceanBase data processing
    • Query acceleration
      • Statistics
      • Materialized views for query acceleration
      • Select a query parallelism level
    • Manage instances
      • Instance overview
      • Change configuration
      • Modify primary zone
      • Manage parameters
      • Backup and restore
        • Backup overview
        • Backup strategies
        • Immediate backup
        • Data backup
        • Initiate restore
        • Data restore
      • Monitor instance performance
        • Overview
        • Monitor the performance of databases in an instance
        • Monitor the performance of hosts in an instance
      • Manage major compactions
        • Initiate a major compaction
        • View compaction records
        • Update time for compactions
      • Database proxy
        • Overview
        • Manage database proxy
        • Direct load
      • Manage alerts
        • Overview
        • Manage alert rules
          • Create an alert rule
          • View an alert rule
          • Edit an alert rule
          • Delete an alert rule
        • View alert history
        • Manage alert templates
          • Create an alert template
          • View an alert template
          • Edit an alert template
          • Copy an alert template
          • Delete an alert template
        • Manage muting rules
          • Create an alert muting rule
          • View an alert muting rule
          • Edit an alert muting rule
          • Delete an alert muting rule
        • Manage alert notification templates
          • Create an alert notification template
          • View an alert notification template
          • Edit an alert notification template
          • Copy an alert notification template
          • Delete an alert notification template
        • Manage alert contacts
          • Add an alert contact
          • Add an alert contact group
          • View an alert contact
          • Edit an alert contact
          • Delete an alert contact
          • Obtain a webhook URL
        • Monitoring metrics for alerts
      • Diagnostics
        • View performance monitoring data
        • Capacity diagnostics
        • Real-time diagnostics
          • SQL diagnostics
            • Top SQL
            • Slow SQL
            • Suspicious SQL
            • High-risk SQL
            • SQL details
            • SQL monitoring metrics list
          • Session management
            • Session management
          • Optimization management
            • Manage active outlines
            • View the optimization history
          • Request analysis
            • Request analysis
      • Stop and restart instances
      • Release instances
      • Manage databases and accounts
        • Create and manage accounts
        • Create a database
        • Manage databases
      • Manage tags
    • Data lifecycle management
      • Archive data
      • Clean up data
    • Performance diagnosis and tuning
      • Use the DBMS_XPLAN package for performance diagnostics
      • Use the GV$SQL_PLAN_MONITOR view for performance analysis
      • Views related to AP performance analysis
    • Performance testing
    • Product integration
    • Manage recycle Bin
      • View instance recycle bin
      • Manage databases and tables in recycle bin
        • Overview
        • Instance recycle bin
  • Work with Key-Value Instances
    • Try out Key-Value instances
      • Create an instance
      • Create a tenant
      • Create an account for a database user
      • OBKV HBase data operation examples
    • Use Table model
      • Create an instance
      • Manage instances
        • Manage instances
          • View the instance list
          • Instance overview
          • Stop and restart instances
          • Release an instance
        • Manage tenants
          • Create a tenant
          • Modify tenant specifications
          • Modify tenant names
          • Delete a tenant
          • Tenant overview
          • Resource isolation
            • Overview
            • Manage resource groups
              • Create a resource group
              • View a resource group
              • Edit a resource group
              • Delete a resource group
            • Manage isolation rules
              • Create an isolation rule
              • View isolation rules
              • Edit an isolation rule
              • Delete a quarantine rule
          • Monitor tenant performance
            • Overview
            • View performance and SQL monitoring details
            • View transaction monitoring details
            • View storage and cache monitoring details
            • OBKV-Table
            • Customize a monitoring dashboard for a tenant
          • Diagnostics
            • Top SQL
          • Manage tenant parameters
            • Manage tenant parameters
            • Parameters for tenants
          • Manage databases and accounts
            • Create and manage accounts
            • Create a database
            • Manage databases
          • Switch primary zone
        • Monitor instance performance
          • Overview
          • Monitor the performance of databases in an instance
          • Monitor multi-dimensional metrics of an instance
          • Monitor the performance of hosts in a cluster
          • Customize monitoring dashboards for an instance
        • Manage major compactions
          • Initiate major compactions
          • View compaction records
          • Update time for compactions
        • Manage instance parameters
          • Parameter management overview
          • Parameters for cluster instances
        • Change instance configurations
          • View history of configuration changes
          • Change configuration
          • Switch the deployment mode
        • Database proxy
          • Overview
          • Manage database proxy
        • Manage alerts
          • Overview
          • Manage alert rules
            • Create an alert rule
            • View an alert rule
            • Edit an alert rule
            • Delete an alert rule
          • View alert history
          • Manage alert templates
            • Create an alert template
            • View an alert template
            • Edit an alert template
            • Copy an alert template
            • Delete an alert template
          • Manage muting rules
            • Create an alert muting rule
            • View an alert muting rule
            • Edit an alert muting rule
            • Delete an alert muting rule
          • Manage alert contacts
            • Add an alert contact
            • Add an alert contact group
            • View an alert contact
            • Edit an alert contact
            • Delete an alert contact
            • Obtain a webhook URL
          • Monitoring metrics for alerts
        • Backup and restore
          • Backup overview
          • Backup strategies
          • Immediate backup
          • Data backup
          • Initiate restore
          • Data restore
        • Diagnostics
          • View performance monitoring data
          • Top SQL
          • Capacity diagnostics
          • Request analysis
        • Manage tags
        • Manage recycle Bin
          • View instance recycle bin
          • Manage databases and tables in recycle bin
            • Overview
            • Instance-level recycle bin
            • Tenant-level recycle bin
    • Use HBase model
      • OBKV-HBase Overview
      • Create an instance
      • Develop in HBase model
        • Connect to an instance by using the OBKV-HBase client
      • Manage instances
        • Manage instances
          • View the instance list
          • Instance overview
          • Stop and restart instances
          • Release an instance
        • Manage tenants
          • Create a tenant
          • Modify tenant specifications
          • Modify tenant names
          • Delete a tenant
          • Tenant overview
          • Resource isolation
            • Overview
            • Manage resource groups
              • Create a resource group
              • View a resource group
              • Edit a resource group
              • Delete a resource group
            • Manage isolation rules
              • Create an isolation rule
              • View isolation rules
              • Edit an isolation rule
              • Delete a quarantine rule
          • Monitor tenant performance
            • Overview
            • View performance and SQL monitoring details
            • View transaction monitoring details
            • View storage and cache monitoring details
            • OBKV-HBase
            • Customize a monitoring dashboard for a tenant
          • Diagnostics
            • Top SQL
          • Manage tenant parameters
            • Manage tenant parameters
            • Parameters for tenants
          • Manage databases and accounts
            • Create and manage accounts
            • Create a database
            • Manage databases
          • Switch primary zone
        • Monitor instance performance
          • Overview
          • Monitor the performance of databases in an instance
          • Monitor multi-dimensional metrics of an instance
          • Monitor the performance of hosts in a cluster
          • Customize monitoring dashboards for an instance
        • Manage major compactions
          • Initiate major compactions
          • View compaction records
          • Update time for compactions
        • Manage instance parameters
          • Parameter management overview
          • Parameters for cluster instances
        • Change instance configurations
          • View history of configuration changes
          • Change configuration
          • Switch the deployment mode
        • Database proxy
          • Overview
          • Manage database proxy
        • Manage alerts
          • Overview
          • Manage alert rules
            • Create an alert rule
            • View an alert rule
            • Edit an alert rule
            • Delete an alert rule
          • View alert history
          • Manage alert templates
            • Create an alert template
            • View an alert template
            • Edit an alert template
            • Copy an alert template
            • Delete an alert template
          • Manage muting rules
            • Create an alert muting rule
            • View an alert muting rule
            • Edit an alert muting rule
            • Delete an alert muting rule
          • Manage alert contacts
            • Add an alert contact
            • Add an alert contact group
            • View an alert contact
            • Edit an alert contact
            • Delete an alert contact
            • Obtain a webhook URL
          • Monitoring metrics for alerts
        • Backup and restore
          • Backup overview
          • Backup strategies
          • Immediate backup
          • Data backup
          • Initiate restore
          • Data restore
        • Diagnostics
          • View performance monitoring data
          • Top SQL
          • Capacity diagnostics
          • Request analysis
        • Manage tags
        • Manage recycle Bin
          • View instance recycle bin
          • Manage databases and tables in recycle bin
            • Overview
            • Instance-level recycle bin
            • Tenant-level recycle bin
      • Performance test
    • Connect Key-Value instances
      • Overview
      • Connect using a public IP address
  • Migrations
    • Data migration and import solutions
    • Data assessment and migration quick start
    • Assess compatibility
      • Overview
      • Perform online assessment
      • Perform offline assessment
      • Manage compatibility assessment tasks
        • View a compatibility assessment task
        • View and download a compatibility assessment report
        • Stop a compatibility assessment task
        • Delete a compatibility assessment task
      • Obtain files for upload
      • Configure PrivateLink
      • Add an IP address to an allowlist
    • Migrate data
      • Overview
      • Migrations specification
      • Purchase a data migration instance
      • Migrate data from a MySQL database to a MySQL-compatible tenant of OceanBase Database
      • Migrate data from a MySQL-compatible tenant of OceanBase Database to a MySQL database
      • Migrate data between OceanBase database tenants of the same compatibility mode
      • Migrate data between OceanBase database tenants of different compatibility modes
      • Migrate data from an Oracle database to an Oracle-compatible tenant of OceanBase Database
      • Migrate data from an Oracle-compatible tenant of OceanBase Database to an Oracle database
      • Configure a two-way synchronization task
      • Migrate data from an OceanBase database to a Kafka instance
      • Migrate data from a TiDB database to a MySQL-compatible tenant of OceanBase Database
      • Migrate incremental data from a MySQL-compatible tenant of OceanBase Database to a TiDB Database
      • Migrate data from a PostgreSQL database to an OceanBase database
      • Migrate incremental data from an OceanBase Database to a PostgreSQL database
      • Manage data migration tasks
        • View details of a data migration task
        • Rename a data migration task
        • View and modify migration objects
        • View and modify migration parameters
        • Configure alert monitoring
        • Manage data migration tasks by using tags
        • Start, stop, and resume a data migration task
        • Clone a data migration task
        • Terminate and release a data migration task
      • Features
        • Custom DML/DDL configurations
        • DDL synchronization scope
        • Use SQL conditions to filter data
        • Rename a migration object
        • Set an incremental synchronization timestamp
        • Instructions on schema migration
        • Configure and modify matching rules
        • Wildcard rules
        • Import migration objects
        • Download conflict data
        • Change a topic
        • Column filtering
        • Data formats
      • Authorize an Alibaba Cloud account
      • SQL statements for querying table objects
      • Online DDL tools
      • Create a trigger
      • Modify the log level of a self-managed PostgreSQL instance
      • Supported DDL statements for synchronization and their limitations
        • DDL synchronization from Aurora MySQL DB clusters to MySQL-compatible tenants of OceanBase Database
        • DDL synchronization from MySQL-compatible tenants of OceanBase Database to Aurora MySQL DB clusters
        • DDL synchronization between MySQL-compatible tenants of OceanBase Database
        • DDL synchronization from Oracle databases to Oracle-compatible tenants of OceanBase Database
        • DDL synchronization from Oracle-compatible tenants of OceanBase Database to Oracle databases
        • DDL synchronization between Oracle-compatible tenants of OceanBase Database
        • DDL synchronization from OceanBase databases to Kafka instances
    • Data subscription
      • Create a data subscription task
      • Manage data subscription tasks
        • View details of a data subscription task
        • Configure subscription information
        • Modify the name of a data subscription task
        • View and modify subscription objects
        • View data subscription parameters
        • Set up data subscription alerts
        • Start, stop, and resume data subscription tasks
        • Clone a data subscription task
        • Release a data subscription task
      • Manage private connections for data subscriptions
      • Configure consumer subscription
      • Message formats
    • Data validation
      • Overview
      • Create a data validation task
      • Manage data validation tasks
        • View details of a data validation task
        • View and modify validation objects
        • View and modify validation parameters
        • Manage data validation tasks with tags
        • Start, pause, and resume data validation tasks
        • Clone a data validation task
        • Release a data validation task
      • Features
        • Import validation objects
        • Rename the validation object
        • Filter objects by using SQL conditions
        • Configure the matching rules for the validation object
    • Assess performance
      • Overview
      • Obtain traffic files from a database instance
      • Create a full performance assessment task
      • Create an SQL file parsing task
      • Create an SQL file replay task
      • Manage performance assessment tasks
        • View the details of a performance assessment task
        • View a performance assessment report
        • Retry and stop a performance assessment task
        • Delete a performance assessment task
      • Obtain a database instance
      • Create an access key
    • Import data
      • Import data
      • Direct load
      • Supported file formats and encoding formats for Data Import
      • Sample data introduction
    • Binlog service
      • Overview
      • Purchase the Binlog service
      • Manage Binlog Service
        • View details of the Binlog service
        • Change configuration
        • Modify the auto-scaling strategy for storage space
        • Modify the elasticity strategy for compute units
        • Disable the Binlog service
  • Security
    • OceanBase Cloud account settings
      • Modify login password
      • Multi-factor authentication
      • Manage AccessKeys
      • Time zone settings
      • Manage cloud marketplace accounts
      • Account audit
    • Organizations and projects
      • Overview
      • Manage organization information
      • Project management
        • Manage projects
        • Cross-project bidirectional authorization
        • Subscribe to project messages
      • Manage members
      • Permissions for roles
      • Cost management
        • Overview
        • Cost details
        • Manage cost units
      • Operation audit
    • Database accounts and privileges
      • Account privileges
      • Authorize cloud vendor accounts
      • AWS KMS key management
      • Support access control
    • Security and encryption
      • Set allowlist groups
      • SSL encryption
      • Transparent Data Encryption (TDE)
    • Monitoring dashboard
    • Events
  • SQL Console
    • Overview
    • Access SQL Console
    • SQL editing and execution
    • PL compilation
    • Result set editing
    • Execution analysis
    • Database object management
      • Create a table
      • Create a view
      • Create a function
      • Create a stored procedure
      • Create a program package
      • Create a trigger
      • Create a type
      • Create a sequence
      • Create a synonym
    • Session variable management
    • Functional keys in SQL Console
  • Integrations
    • Overview
    • Schema evolution
      • Liquibase
      • Flyway
    • Data ingestion
      • Canal
      • dbt
      • Debezium
      • Flink
      • Glue
      • Informatica Cloud
      • Kafka
      • Maxwell
      • SeaTunnel
      • DataWorks
      • NiFi
    • SQL development
      • DataGrip
      • DBeaver
      • Navicat
      • TablePlus
    • Orchestration
      • DolphinScheduler
      • Linkis
      • Airflow
    • Visualization
      • Grafana
      • Power BI
      • Quick BI
      • Superset
      • Tableau
    • Observability
      • Datadog
      • Prometheus
    • Database management
      • Bytebase
    • AI
      • LlamaIndex
      • Dify
      • LangChain
      • Tongyi Qianwen
      • OpenAI
      • n8n
      • Trae
      • SpringAI
      • Cline
      • Cursor
      • Continue
      • Toolbox
      • CamelAI
      • Firecrawl
      • Hugging Face
      • Ollama
      • Google Gemini
      • Cloudflare Workers AI
      • Jina AI
      • Augment Code
      • Claude Code
      • Kiro
    • Development tools
      • Cloudflare Workers
      • Vercel
  • Best practices
    • Best practices for achieving high availability through cross-cloud active-active deployment
    • High availability through cross-cloud primary-standby databases (1:1)
    • High availability through cross-cloud primary-standby databases (1:n)
    • High host CPU usage
    • Best practices for read/write splitting in OceanBase Cloud
  • References
    • System architecture
    • System management
    • Database object management
    • Database design and specification constraints
    • SQL reference
    • System views
    • Parameters and system variables
    • Error codes
    • Performance tuning
    • Open API References
      • Overview
      • Service endpoints
      • Using API
      • Open APIs
        • Cluster management
          • DescribeInstances
          • DescribeInstance
          • CreateInstance
          • DeleteInstance
          • ModifyInstanceName
          • describe-node-options
          • StopCluster
          • StartCluster
          • ModifyInstanceSpec
          • DescribeInstanceTopology
          • DescribeReadonlyInstances
          • CreateReadonlyInstance
          • ModifyReadonlyInstanceSpec
          • ModifyReadonlyInstanceDiskSize
          • ModifyReadonlyInstanceNodeNum
          • DeleteReadonlyInstance
          • DescribeInstanceAvailableRoZones
          • DescribeInstanceParameters
          • UpdateInstanceParameters
          • DescribeInstanceParametersHistory
          • ModifyInstanceTagList
          • ModifyInstanceNodeNum
        • Tenant management
          • DescribeTenants
          • DescribeTenant
          • CreateTenants
          • DeleteTenants
          • ModifyTenantName
          • ModifyTenant
          • ModifyTenantUserDescription
          • ModifyTenantUserStatus
          • GetTenantCreateConstraints
          • ModifyTenantPrimaryZone
          • GetTenantCreateCpuConstraints
          • GetTenantCreateMemConstraints
          • GetTenantModifyCpuConstraints
          • GetTenantModifyMemConstraints
          • CreateTenantSecurityIpGroup
          • DescribeTenantSecurityIpGroups
          • ModifyTenantSecurityIpGroup
          • DeleteTenantSecurityIpGroup
          • DescribeTenantPrivateLink
          • DeletePrivatelinkConnection
          • CreatePrivatelinkService
          • ConnectPrivatelinkService
          • AddPrivatelinkServiceUser
          • BatchKillProcessList
          • DescribeProcessStatsComposition
          • DescribeTenantAvailableRoZones
          • DescribeTenantAddressInfo
          • ModifyTenantReadonlyReplica
          • DescribeTenantParameters
          • UpdateTenantParameters
          • DescribeTenantParametersHistory
          • ModifyTenantTagList
        • Tenant user management
          • CreateTenantUser
          • DescribeTenantUsers
          • DeleteTenantUsers
          • ModifyTenantUserPassword
          • ModifyTenantUserRoles
        • Database management
          • CreateDatabase
          • DescribeDatabases
          • DeleteDatabases
          • ModifyDatabaseUserRoles
        • Backup and restore
          • DescribeDataBackupSet
          • DescribeRestorableTenants
          • ModifyBackupStrategy
          • CreateTenantRestoreTask
          • CreateDataBackupTask
          • DescribeOneDataBackupSet
        • Database proxy management
          • CreateTenantAddress
          • CreateTenantSingleTunnelSLBAddress
          • DeleteTenantAddress
          • DescribeTenantAddress
          • ModifyOdpClusterSpec
          • ModifyTenantAddressPort
          • ModifyTenantAddressDomainPrefix
          • ConfirmPrivatelinkConnection
          • DescribeTenantAddressInfo
        • Monitoring management
          • DescribeTenantMetrics
          • DescribeMetricsData
          • DescribeNodeMetrics
        • Diagnostic management
          • DescribeOasTopSQLList
          • DescribeOasAnomalySQLList
          • DescribeOasSlowSQLList
          • DescribeOasSQLText
          • DescribeSqlAudits
          • DescribeOutlineBinding
          • DescribeSampleSqlRawTexts
          • DescribeSQLTuningAdvices
          • DescribeOasSlowSQLSamples
          • DescribeOasSQLTrends
          • DescribeOasSQLPlanGroup
        • Security management
          • CreateSecurityIpGroup
          • DescribeInstanceSSL
          • ModifyInstanceSSL
          • DescribeTenantEncryption
          • ModifyTenantEncryption
          • ModifySecurityIps
          • DeleteSecurityIpGroup
          • DescribeTenantSecurityConfigs
          • DescribeInstanceSecurityConfigs
        • Tag management
          • DescribeTags
          • CreateTags
          • UpdateTag
          • DeleteTag
        • Historical event management
          • DescribeOperationEvents
      • Differences between ApsaraDB for OceanBase APIs and OceanBase Cloud APIs
    • Download OBClient
      • Download OBClient
      • Download OceanBase Connector/J
      • Download client ODC
      • Download OceanBase Connector/ODBC
      • Download OBClient Libs
    • Metrics References
      • Cluster database
      • Cluster hosts
      • Binlog service
      • Cross-cloud network channel connection
      • Performance and SQL
      • Transactions
      • Storage and caching
      • Proxy database
      • Proxy host
    • ODC User Guide
      • What is ODC?
        • What is ODC?
        • Limitations
      • Quick Start
        • Client ODC
          • Overview
          • Install Client ODC
          • Use Client ODC
        • Web ODC
          • Overview
          • Use Web ODC
      • Data Source Management
        • Create a data source
        • Data sources and project collaboration
        • Database O&M
          • Session management
          • Global variable management
          • Recycle bin management
      • SQL Development
        • Edit and execute SQL statements
        • Perform PL compilation and debugging
        • Edit and export the result set of an SQL statement
        • Execution analysis
        • Generate test data
        • System settings
        • Database objects
          • Table objects
            • Overview
            • Create a table
          • View objects
            • Overview
            • Create a view
            • Manage views
          • Materialized view objects
            • Overview
            • Create a materialized view
            • Manage materialized views
          • Function objects
            • Overview
            • Create a function
            • Manage functions
          • Stored procedure objects
            • Overview
            • Create a stored procedure
            • Manage stored procedures
          • Sequence objects
            • Overview
            • Create a sequence
            • Manage sequences
          • Package objects
            • Overview
            • Create a program package
            • Manage program packages
          • Trigger objects
            • Overview
            • Create a trigger
            • Manage triggers
          • Type objects
            • Overview
            • Create a type
            • Manage types
          • Synonym objects
            • Overview
            • Create a synonym
            • Manage synonyms
      • Import and Export
        • Import schemas and data
        • Export schemas and data
      • Database Change Management
        • User Permission Management
          • Users and roles
          • Automatic authorization
          • User permission management
        • Project collaboration management
        • Risk levels, risk identification rules, and approval processes
        • SQL check specifications
        • SQL window specification
        • Database change management
        • Batch database change management
        • Online schema changes
        • Synchronize shadow tables
        • Schema comparison
      • Data Lifecycle Management
        • Partitioning Plan Management
          • Manage partitioning plans
          • Set partitioning strategies
          • Examples
        • SQL plan task
      • Data Desensitization and Auditing
        • Desensitize data
        • Operation records
      • Notification Management
        • Overview
        • View notification records
        • Manage Notification Channel
          • Create a notification channel
          • View, edit, and delete a notification channel
          • Configure a custom channel
        • Manage notification rules
      • Best Practices
        • Tips for SQL development
        • Explore ODC team workspaces
        • Understanding real-time SQL diagnostics for OceanBase AP
        • OceanBase historical database solutions
        • ODC SQL check for automatic identification of high-risk operations
        • Manage and modify sharded databases and tables via ODC
        • Data masking and control practices
        • Enterprise-level control and collaboration: Safeguard every database change
    • Data Development
      • Overview
      • Workspace management
      • Worksheet management
      • Compute node pool management
      • Workflow management
      • Dashboard management
      • Manage Git repositories
      • SQL development
        • SQL editing and execution
        • Result set editing
        • Execution analysis
        • Database object management
          • Create a table
          • Create a view
          • Create a function
          • Create a stored procedure
        • Session variable management
        • Git integration
      • Sample datasets
      • Data development terms
  • Manage Billing
    • Access billing
    • View monthly bills
    • View payment details
    • View orders
    • Use vouchers for payment
    • View invoices
  • Legal Agreements
    • OceanBase Cloud Services Agreement
    • Service Level Agreement
    • OceanBase Data Processing Addendum
    • Service Level Agreement for OceanBase Cloud Migration Service

Download PDF

Release notes for 2026 Release notes for 2025 Release notes for 2024 Release history Data development module deprecation notice Optimization of Backup and Restore commercialization strategy Cross-AZ data transfer billing (OceanBase Cloud on AWS) Database Proxy pricing update AWS instance pricing adjustment Overview Management mode and scenarios High availability with cross-cloud active-active architecture High availability with cross-cloud primary-standby databases Multi-level caching in shared storage Multi-layer online scaling and on-demand adjustment Deployment modes Storage architecture Product specifications Overview Backup and restore billing SQL audit billing Migrations billing Database proxy billing Binlog service billing Overview of OceanBase Cloud support plans Read-only replica billing Supported database versions Get started with a transactional instance Get started with an analytical instance Get started with a Key-Value instance Overview Overview Create via OceanBase Cloud official website Create via AWS Marketplace Create via GCP Marketplace Create via Huawei Cloud Marketplace Create via Alibaba Cloud Marketplace Create via Azure Marketplace Release an instance Manage tags Manage JVM-dependent services Create a data source Manage data sources Archive data Clean up data Instance recycle bin Overview Core features Create an instance Overview Table overview Export data OceanBase data processing Statistics Materialized views for query acceleration Select a query parallelism level Instance overview Change configuration Modify primary zone Manage parameters Stop and restart instances Release instances Manage tags Archive data Clean up data Use the DBMS_XPLAN package for performance diagnostics Use the GV$SQL_PLAN_MONITOR view for performance analysis Views related to AP performance analysis Performance testing Product integration View instance recycle bin Create an instance Create a tenant Create an account for a database user OBKV HBase data operation examples Create an instance OBKV-HBase Overview Create an instance Performance test Overview Connect using a public IP address Data migration and import solutions Data assessment and migration quick start Overview Perform online assessment Perform offline assessment Obtain files for upload Configure PrivateLink Add an IP address to an allowlist Overview Migrations specification Purchase a data migration instance Migrate data from a MySQL database to a MySQL-compatible tenant of OceanBase Database Migrate data from a MySQL-compatible tenant of OceanBase Database to a MySQL database Migrate data between OceanBase database tenants of the same compatibility mode Migrate data between OceanBase database tenants of different compatibility modes Migrate data from an Oracle database to an Oracle-compatible tenant of OceanBase Database Migrate data from an Oracle-compatible tenant of OceanBase Database to an Oracle database Configure a two-way synchronization task Migrate data from an OceanBase database to a Kafka instance
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 Cloud
iconOceanBase Cloud

    C3P0 connection pool connects to OceanBase Cloud

    Last Updated:2026-04-07 08:08:33  Updated
    share
    What is on this page
    Prerequisites
    Procedure
    Step 1: Import the c3p0-oceanbase-jdbc project into Eclipse
    Step 2: Modify the database connection information in the c3p0-oceanbase-jdbc project
    Step 3: Run the c3p0-oceanbase-jdbc project
    Project code
    Introduction to the pom.xml file
    Introduction to c3p0-config.xml
    Main.java code introduction
    Complete code
    References

    folded

    share

    This topic describes how to use the C3P0 connection pool, OceanBase Connector/J, and OceanBase Cloud to build an application that performs basic database operations, including table creation, data insertion, data deletion, data updating, and data query.

    Download the c3p0-oceanbase-jdbc sample project C3P0 connection pool connects to OceanBase Cloud (Oracle compatible mode)

    Prerequisites

    • You have registered an account for OceanBase Cloud and created an instance and an OceanBase Cloud Oracle-compatible tenant. For more information, see Create an instance and Create a tenant.

    • You have obtained the connection string of the target Oracle-compatible tenant. For more information, see Obtain the connection string.

    • You have installed JDK 1.8 and Maven.

    • You have installed Eclipse.

      Note

      The code in this topic is run in Eclipse IDE for Java Developers 2022-03. You can also use any other tool that you prefer to run the sample code.

    Procedure

    Note

    The following steps describe how to compile and run the c3p0-oceanbase-jdbc project in Eclipse IDE for Java Developers 2022-03 on Windows. If you are using a different operating system or compiler, the steps may vary slightly.

    Step 1: Import the c3p0-oceanbase-jdbc project into Eclipse

    1. Open Eclipse and select File > Open Projects from File System.

    2. In the dialog box that appears, click Directory to select the project directory, then click Finish to complete the import.

      Note

      When importing a Maven project into Eclipse, it automatically detects the pom.xml file in the project, downloads the required dependency libraries based on the described dependencies in the file, and adds them to the project.

      Import

    3. View the project.

      p1

    Step 2: Modify the database connection information in the c3p0-oceanbase-jdbc project

    Modify the database connection information in the c3p0-oceanbase-jdbc/src/main/resources/c3p0-config.xml file based on the connection string obtained in the prerequisites.

    Here is an example:

    ...
            <property name="jdbcUrl">jdbc:oceanbase://t5******.********.oceanbase.cloud:1521/test?useSSL=false&amp;useUnicode=true&amp;characterEncoding=utf8</property>
            <property name="user">test_user</property>
            <property name="password">******</property>
    ...
    
    • The connection address is t5******.********.oceanbase.cloud.
    • The access port is 1521.
    • The database name to be accessed is test.
    • The tenant connection account is test_user.
    • The password is ******.

    Step 3: Run the c3p0-oceanbase-jdbc project

    1. In the Project Explorer view, locate and expand the src/main/java directory.

    2. Right-click the Main.java file and select Run As > Java Application.

      run

    3. View the project logs and output results in the Eclipse console window.

      log

    4. You can also execute the following SQL statement in OceanBase Client (OBClient) to view the results.

      obclient [SYS]> SELECT * FROM test_schema001.test_c3p0;
      

      The returned result is as follows:

      +------+--------------+
      | ID   | NAME         |
      +------+--------------+
      |    5 | test_update  |
      |    6 | test_insert6 |
      |    7 | test_insert7 |
      |    8 | test_insert8 |
      |    9 | test_insert9 |
      +------+--------------+
      5 rows in set
      

    Project code

    Click c3p0-oceanbase-jdbc to download the project code, which is a compressed file named c3p0-oceanbase-jdbc.zip.

    After decompressing the file, you will find a folder named c3p0-oceanbase-jdbc. The directory structure is as follows:

    c3p0-oceanbase-jdbc
    ├── src
    │   └── main
    │       ├── java
    │       │   └── com
    │       │        └── example
    │       │           └── Main.java
    │       └── resources
    │           └── c3p0-config.xml 
    └── pom.xml
    

    File description:

    • src: the root directory for source code.
    • main: the main code directory, containing the core logic of the application.
    • java: the directory for Java source code.
    • com: the directory for Java packages.
    • example: the directory for packages of the sample project.
    • Main.java: the main class, containing logic for creating tables and inserting data.
    • resources: the directory for resource files, including configuration files.
    • c3p0-config.xml: the configuration file for the C3P0 connection pool.
    • pom.xml: the configuration file for the Maven project, used to manage project dependencies and build settings.

    Introduction to the pom.xml file

    The pom.xml file is a configuration file for Maven projects, defining dependencies, plugins, and build rules. Maven is a Java project management tool that can automatically download dependencies, compile, and package projects.

    The pom.xml file in this article mainly includes the following parts:

    1. File declaration statement.

      This statement declares the file as an XML file using XML version 1.0 and character encoding UTF-8.

      Sample code:

      <?xml version="1.0" encoding="UTF-8"?>
      
    2. Configure the namespace and POM model version.

      1. Use xmlns to specify the POM namespace as http://maven.apache.org/POM/4.0.0.
      2. Use xmlns:xsi to specify the XML namespace as http://www.w3.org/2001/XMLSchema-instance.
      3. Use xsi:schemaLocation to specify the POM namespace as http://maven.apache.org/POM/4.0.0 and the location of the POM XSD file as http://maven.apache.org/xsd/maven-4.0.0.xsd.
      4. Use <modelVersion> to specify the POM model version used by the POM file as 4.0.0.

      Sample code:

      <project xmlns="http://maven.apache.org/POM/4.0.0"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
      
       <!-- Other configurations -->
      
      </project>
      
    3. Configure basic information.

      1. Use <groupId> to specify the project's organization as com.example.
      2. Use <artifactId> to specify the project name as testc3p0.
      3. Use <version> to specify the project version as 1.0-SNAPSHOT.

      Sample code:

          <groupId>com.example</groupId>
          <artifactId>testc3p0</artifactId>
          <version>1.0-SNAPSHOT</version>
      
    4. Configure the properties of the project's source files.

      Specify the Maven compiler plugin as maven-compiler-plugin and set the source and target Java versions to 8. This means the project's source code is written using Java 8 features, and the compiled bytecode will also be compatible with the Java 8 runtime environment. This setup ensures that the project can correctly handle Java 8 syntax and features during compilation and runtime.

      Note

      Java 1.8 and Java 8 are different names for the same version.

      Sample code:

          <build>
              <plugins>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-compiler-plugin</artifactId>
                      <configuration>
                          <source>8</source>
                          <target>8</target>
                      </configuration>
                  </plugin>
              </plugins>
          </build>
      
    5. Configure the components that the project depends on.

      Note

      This section defines the project's dependency on OceanBase Connector/J V2.4.2. For information about other versions, see OceanBase JDBC driver

      Use <dependency> to define dependencies:

      • oceanbase-client dependency:

        1. Use <groupId> to specify the dependency's organization as com.oceanbase.
        2. Use <artifactId> to specify the dependency name as oceanbase-client.
        3. Use <version> to specify the dependency version as 2.4.2.
      • C3P0 dependency:

        1. Use <groupId> to specify the dependency's organization as com.mchange.
        2. Use <artifactId> to specify the dependency name as c3p0.
        3. Use <version> to specify the dependency version as 0.9.5.5.

      Sample code:

          <dependencies>
              <dependency>
                  <groupId>com.oceanbase</groupId>
                  <artifactId>oceanbase-client</artifactId>
                  <version>2.4.2</version>
              </dependency>
              <dependency>
                  <groupId>com.mchange</groupId>
                  <artifactId>c3p0</artifactId>
                  <version>0.9.5.5</version>
              </dependency>
          </dependencies>
      

    Introduction to c3p0-config.xml

    The c3p0-config.xml file is a C3P0 connection pool configuration file used to configure properties related to database connections. By setting the values of various <property> elements, you can configure properties such as the database driver, connection URL, username, password, and connection pool size.

    The code in the c3p0-config.xml file in this topic mainly includes the following parts:

    1. A file declaration statement.

      This statement declares the file to be an XML file that uses XML version 1.0 and character encoding UTF-8.

      Sample code:

      <?xml version="1.0" encoding="UTF-8"?>
      
    2. Basic configuration.

      1. The <c3p0-config> element is used to include the configuration information of the c3p0 connection pool.
      2. The <named-config name="oceanbase"> element defines a named configuration named oceanbase. In the code, you can use this name to reference the named configuration and obtain connection information and connection pool properties related to the oceanbase database.

      Sample code:

      <c3p0-config>
          <named-config name="oceanbase">
      
              // Configure the values of various <property> elements
      
          </named-config>
      </c3p0-config>
      
    3. Database driver configuration.

      The <property> element is used to specify the class name of the JDBC driver for connecting to the OceanBase database as com.oceanbase.jdbc.Driver.

      Sample code:

              <property name="driverClass">com.oceanbase.jdbc.Driver</property>
      
    4. Database connection information configuration.

      1. The database connection URL is set, including the connection address, port number, schema to be accessed, and URL parameters.
      2. The database username is configured.
      3. The database password is configured.

      Sample code:

              <property name="jdbcUrl">jdbc:oceanbase://$host:$port/$schema_name?useSSL=false&amp;useUnicode=true&amp;characterEncoding=utf8</property>
              <property name="user">$user_name</property>
              <property name="password">$password</property>
      

      Parameter description:

      • $host: The value of the -h parameter in the connection string, which specifies the connection address of the OceanBase Cloud database.

      • $port: The value of the -P parameter in the connection string, which specifies the connection port of the OceanBase Cloud database.

      • $schema_name: The value of the -D parameter in the connection string, which specifies the name of the database to be accessed.

      • Other parameters are as follows:

        • useSSL=false: Disables SSL encryption, indicating that secure socket layer is not used to protect data transmission.
        • seUnicode=true: Enables Unicode character encoding to ensure that various character sets can be processed correctly.
        • characterEncoding=utf8: Specifies the use of UTF-8 character encoding.
        • &amp;: An XML entity reference used to represent the & character. In XML, & is a special character that must be represented by an entity reference to avoid conflicts with XML syntax.

        For more information about URL parameters, see Database URL.

      • $user_name: The value of the -u parameter in the connection string, which specifies the account name.

      • $password: The value of the -p parameter in the connection string, which specifies the account password.

    5. Other c3p0 connection pool configuration items.

      1. The number of connections to be added at a time when the connection pool needs more connections is set to 20. That is, when the number of connections in the connection pool is insufficient, 20 connections are added each time.
      2. The initial size of the connection pool is set to 10. That is, 10 connections are pre-created when the connection pool is started.
      3. The minimum number of connections in the connection pool is set to 5. That is, the number of connections kept in the connection pool is not less than 5.
      4. The maximum number of connections in the connection pool is set to 30. That is, the number of connections allowed in the connection pool does not exceed 30.
      5. The maximum number of cached statements per connection is set to 0. That is, no statements are cached.
      6. The maximum number of cached statements per connection in the connection pool is set to 0. That is, no statements are cached per connection.
      7. The number of auxiliary threads used by c3p0 is set to 3. These auxiliary threads are used to execute slow JDBC operations.
      8. The attribute check cycle for c3p0 connections is set to 3 seconds. That is, the attributes of connections are checked every 3 seconds.
      9. The timeout period for obtaining a connection is set to 1000 milliseconds. That is, if a connection cannot be obtained within 1000 milliseconds, a timeout exception is thrown.
      10. The idle connection check cycle in the connection pool is set to 3 seconds. That is, the status of idle connections is checked every 3 seconds.
      11. The maximum idle time of a connection in the connection pool is set to 10 seconds. That is, if a connection is not used for 10 seconds, it will be closed.
      12. The maximum idle time of a connection exceeding the maximum number of connections in the connection pool is set to 5 seconds. That is, if a connection exceeds the maximum number of connections and is idle for more than 5 seconds, it will be closed.
      13. The retry delay when attempting to obtain a connection is set to 1000 milliseconds. That is, if obtaining a connection fails, it will be retried after 1000 milliseconds.
      14. The automatic test table for c3p0 is set to "test". This is a special table used to test whether a connection is valid.
      15. Whether to test the validity of a connection when returning it to the connection pool is set. If set to true, the validity of a connection is tested when it is returned to the connection pool.

      Sample code:

             <property name="acquireIncrement">20</property>
             <property name="initialPoolSize">10</property>
             <property name="minPoolSize">5</property>
             <property name="maxPoolSize">30</property>
             <property name="maxStatements">0</property>
             <property name="maxStatementsPerConnection">0</property>
             <property name="numHelperThreads">3</property>
             <property name="propertyCycle">3</property>
             <property name="checkoutTimeout">1000</property>
             <property name="idleConnectionTestPeriod">3</property>
             <property name="maxIdleTime">10</property>
             <property name="maxIdleTimeExcessConnections">5</property>
             <property name="acquireRetryDelay">1000</property>
             <property name="automaticTestTable">test</property>
             <property name="testConnectionOnCheckin">true</property>
      

    Notice

    The specific property (parameter) configuration depends on the project requirements and database characteristics. We recommend that you adjust and configure the parameters based on your actual situation. For more information about C3P0 connection pool parameters, see C3P0.

    Common basic configuration items of the C3P0 connection pool:

    Category Attribute Default value Description
    Required driverClass N/A The name of the driver class.
    jdbcUrl N/A The URL of the database to connect to.
    user N/A The username to use when connecting to the database.
    password N/A The password to use when connecting to the database.
    Basic acquireIncrement 3 The number of connections to acquire at once when the connection pool needs connections. For example, if acquireIncrement is set to 20 and there are only 5 idle connections in the connection pool, the pool will create 20 new connections to meet the application's needs when connections are requested.
    acquireRetryAttempts 30 The number of retries to attempt when acquiring a connection from the connection pool. If this value is less than or equal to zero, C3P0 will continue to attempt to acquire a connection indefinitely.
    maxIdleTime 0 The maximum idle time for a connection in the connection pool, in seconds. A value of 0 means that idle connections will never expire. For example, if maxIdleTime is set to 10 seconds, any idle connection in the pool that is not used for more than 10 seconds will be closed and removed from the pool. The next time the application requests a connection, the pool will create a new one.
    maxPoolSize 15 The maximum number of connections in the connection pool. When the number of connections in the pool reaches the value specified by maxPoolSize, new connection requests will be blocked until a connection is released back to the pool.
    MinPoolSize 3 The minimum number of connections in the connection pool. The pool will maintain at least the number of connections specified by minPoolSize even when connections are not in use.
    initialPoolSize 3 The number of connections to pre-create when the connection pool starts. This value should be between minPoolSize and maxPoolSize. That is, when the pool is initialized, it will create the number of connections specified by initialPoolSize.
    Optional acquireRetryDelay 1000 The retry delay time in milliseconds when acquiring a connection. When an application requests a connection from the pool and no available connections are found, the pool may fail to acquire a connection. In this case, the pool will retry based on the configuration of acquireRetryDelay.
    autoCommitOnClose false Whether to automatically commit transactions when the connection is closed. The default value is false, meaning that transactions will not be automatically committed when the connection is closed. If the application needs to explicitly commit transactions before closing the connection, set autoCommitOnClose to true.

    Notice

    Automatic transaction commit may lead to data inconsistency or loss. Therefore, autoCommitOnClose should be used with caution to ensure transaction integrity. In most cases, it is recommended to manually manage transactions to ensure that commits or rollbacks occur at appropriate times.

    automaticTestTable null The name of the automatic test table for the connection pool. C3P0 will create an empty table with the specified name and use queries on this table to test the connection. The default value is null, indicating that no test statements will be executed. For example, if automaticTestTable is set to test, C3P0 will create an empty table named test and use its built-in query statements for testing.

    Note

    If both automaticTestTable and preferredTestQuery are configured in the connection pool, C3P0 will prioritize using preferredTestQuery for test queries and ignore the settings of automaticTestTable.

    idleConnectionTestPeriod 0 The interval in milliseconds for idle connection detection in the connection pool. That is, the pool will periodically test idle connections at the specified intervals. The default value is 0, indicating that no idle connection detection will be performed.
    maxStatements 0 The maximum number of prepared statements in the connection pool.

    Note

    • If both maxStatements and maxStatementsPerConnection are set to 0, statement caching will be disabled.
    • If maxStatements is 0 but maxStatementsPerConnection is a non-zero value, statement caching will be enabled, but the global limit will not be enforced. Only the per-connection limit will take effect.
    • maxStatements controls the total number of cached statements across all connections in the pool. If maxStatements is set, it should be a relatively large number because each connection in the pool requires its own, separate set of cached statements.

    maxStatementsPerConnection 0 Specifies the maximum number of prepared statements allowed per connection.

    Note

    • If both maxStatements and maxStatementsPerConnection are set to 0, statement caching is disabled.
    • If maxStatementsPerConnection is set to 0 but maxStatements is set to a non-zero value, statement caching is enabled and a global limit is enforced, but no statement limit is set for individual connections.

    numHelperThreads 3 Specifies the number of helper threads used for asynchronous task processing.

    Note

    • The more helper threads, the more tasks can be processed in parallel, thereby improving the processing capability and response speed of the connection pool.
    • Setting too many helper threads may lead to excessive consumption of system resources. Therefore, the value of numHelperThreads should be set reasonably based on the hardware configuration and performance testing of the system.

    preferredTestQuery null Specifies the test statement executed for all connection tests. Using connection testing can significantly improve the test speed.

    Notice

    The test table must exist when the data source is initialized.

    checkoutTimeout 0 Specifies the timeout for obtaining a connection from the connection pool, in milliseconds. The default value of 0 indicates no timeout. When the connection pool is exhausted, the client calls getConnection() and waits for a new connection. If the timeout is reached, a SQLException is thrown.
    Not recommended breakAfterAcquireFailure false Controls whether to interrupt the connection pool's acquisition operation when a connection acquisition fails. If a connection acquisition fails, all threads waiting for a connection from the connection pool will throw an exception. However, the data source remains valid and will continue to attempt to acquire a connection on the next call to getConnection().
    • If set to true, the connection pool will stop attempting to acquire connections and will quickly fail, throwing an exception after multiple failed attempts.
    • If set to false, the connection pool will continue to attempt to acquire connections until the connection acquisition timeout is reached.
    testConnectionOnCheckout false Specifies whether to test the connection when obtaining it from the connection pool.
    • If set to true, a connection test is performed when obtaining a connection. This feature should be used with caution as it will result in at least double the number of database calls.
    • If set to false, no connection test is performed.

    Note

    While executing a connection test ensures the connection is valid, it also incurs additional overhead. Therefore, whether to enable connection testing should be decided based on specific application requirements and performance needs. If the application has high availability requirements for connections, connection testing can be enabled. However, if connections are frequently acquired and released from the connection pool, it may lead to excessive connection testing, which can impact performance.

    testConnectionOnCheckin false Specifies whether to test the connection when returning it to the connection pool.
    • If set to true, a connection test is performed when returning a connection to the connection pool. This feature should be used with caution as it will result in at least double the number of database calls.
    • If set to false, no connection test is performed.

    Note

    While executing a connection test ensures the connection is valid, it also incurs additional overhead. Therefore, whether to enable connection testing should be decided based on specific application requirements and performance needs. If the application has high availability requirements for connections, connection testing can be enabled. However, if connections are frequently acquired and released from the connection pool, it may lead to excessive connection testing, which can impact performance.

    Main.java code introduction

    The Main.java file is part of the sample program, demonstrating how to obtain a database connection using the c3p0 connection pool, and perform a series of database operations within a transaction, including creating a table, inserting data, deleting data, updating data, querying data, and printing the query results. It shows how to use the c3p0 connection pool to manage database connections and execute transaction operations to improve the efficiency and performance of database operations.

    The code in the Main.java file in this topic mainly includes the following parts:

    1. Define the package and import the java.sql interface.

      1. Declare the package name of the current code as com.example.
      2. Import the java.sql.Connection class, which is used to represent a database connection.
      3. Import the java.sql.PreparedStatement class, which is used to execute precompiled database operations.
      4. Import the java.sql.ResultSet class, which is used to represent a database query result set.
      5. Import the com.mchange.v2.c3p0.ComboPooledDataSource class, which is used to use the c3p0 connection pool.

      Code:

      package com.example;
      
      import java.sql.Connection;
      import java.sql.PreparedStatement;
      import java.sql.ResultSet;
      import com.mchange.v2.c3p0.ComboPooledDataSource;
      
    2. Define the class name and method.

      1. Define a public class named Main as the entry point of the program. The class name must be consistent with the file name.
      2. Define a public static method main as the starting point of the program.
      3. Use the try-with-resources statement to obtain a database connection and create a precompiled SQL statement.
      4. Perform database transaction operations.
      5. Capture any exceptions that may occur and print the exception stack information.
      6. Define a private static method getConnection to obtain a database connection from the c3p0 connection pool. Inside the method, first create a ComboPooledDataSource object cpds that specifies the connection pool configuration through the parameter oceanbase. Then, obtain a database connection from the connection pool using the cpds.getConnection() method and return it.

      Code:

      public class Main {
      
          public static void main(String[] args) {
              try (
                  // Obtain a database connection
                  // Create a precompiled SQL statement
                  ) {
      
                  // Database transaction operations: start transaction, create table, insert data, delete data, update data, query data, and commit transaction
      
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      
          private static Connection getConnection() throws Exception {
              ComboPooledDataSource cpds = new ComboPooledDataSource("oceanbase");
              return cpds.getConnection();
          }
      }
      
    3. Obtain a database connection.

      Obtain a database connection and assign it to the conn variable.

      Code:

                   Connection conn = getConnection();
      
    4. Create a precompiled SQL statement.

      1. Create a precompiled SQL statement for creating a database table named test_c3p0.
      2. Create a precompiled SQL statement for inserting data into the test_c3p0 table.
      3. Create a precompiled SQL statement for deleting data from the test_c3p0 table.
      4. Create a precompiled SQL statement for updating data in the test_c3p0 table.
      5. Create a precompiled SQL statement for querying data from the test_c3p0 table.

      Code:

                   PreparedStatement stmtCreate = conn.prepareStatement("CREATE TABLE test_c3p0 (id NUMBER, name VARCHAR2(32))");
                   PreparedStatement stmtInsert = conn.prepareStatement("INSERT INTO test_c3p0 VALUES (?, ?)");
                   PreparedStatement stmtDelete = conn.prepareStatement("DELETE FROM test_c3p0 WHERE id < ?");
                   PreparedStatement stmtUpdate = conn.prepareStatement("UPDATE test_c3p0 SET name = ? WHERE id = ?");
                   PreparedStatement stmtSelect = conn.prepareStatement("SELECT * FROM test_c3p0")
      
    5. Start a transaction.

      Set the auto-commit mode of the database connection to false to enable the transaction mechanism.

      Code:

                  conn.setAutoCommit(false); 
      
    6. Create a table.

      Execute the SQL statement for creating a table.

      Code:

                  stmtCreate.execute();
      
    7. Insert data.

      Use a for loop to insert 10 rows of data into the test_c3p0 table. The value of the first column is the value of the variable i, and the value of the second column is the string test_insert concatenated with the value of the variable i.

      Code:

                  for (int i = 0; i < 10; i++) {
                      stmtInsert.setInt(1, i);
                      stmtInsert.setString(2, "test_insert" + i);
                      stmtInsert.executeUpdate();
                  }
      
    8. Delete data.

      Set the parameter of the delete statement to 5 and execute the delete operation.

      Code:

                  stmtDelete.setInt(1, 5);
                  stmtDelete.executeUpdate();
      
    9. Update data.

      Set the first parameter of the update statement to test_update and the second parameter to 5, and execute the update operation.

      Code:

                  stmtUpdate.setString(1, "test_update");
                  stmtUpdate.setInt(2, 5);
                  stmtUpdate.executeUpdate();
      
    10. Query data.

      1. Execute the query statement and save the query results in the ResultSet object rs.
      2. Use a while loop to check if there are more rows of data in the result set by calling rs.next(). If there are, execute the code inside the loop.
      3. The code inside the loop prints the values of the id and name columns for each row.
      4. Close the result set and release the related resources.

      Code:

                  ResultSet rs = stmtSelect.executeQuery();
                  while (rs.next()) {
                      System.out.println(rs.getInt("id") + "   " + rs.getString("name"));
                  }
                  rs.close();
      
    11. Commit the transaction.

      Code:

                  conn.commit(); 
      

    Complete code

    pom.xml
    c3p0-config.xml
    Main.java
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>com.example</groupId>
        <artifactId>testc3p0</artifactId>
        <version>1.0-SNAPSHOT</version>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>8</source>
                        <target>8</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    
        <dependencies>
            <dependency>
                <groupId>com.oceanbase</groupId>
                <artifactId>oceanbase-client</artifactId>
                <version>2.4.2</version>
            </dependency>
            <dependency>
                <groupId>com.mchange</groupId>
                <artifactId>c3p0</artifactId>
                <version>0.9.5.5</version>
            </dependency>
        </dependencies>
    </project>
    
    <?xml version="1.0" encoding="UTF-8"?>
    <c3p0-config>
        <named-config name="oceanbase">
            <!-- Configure Database Driver -->
            <property name="driverClass">com.oceanbase.jdbc.Driver</property>
            <!-- Configure Database Link Address -->
            <property name="jdbcUrl">jdbc:oceanbase://$host:$port/$schema_name?useSSL=false&amp;useUnicode=true&amp;characterEncoding=utf8</property>
            <!-- Configure database username -->
            <property name="user">$user_name</property>
            <!-- Configure database password -->
            <property name="password">$password</property>
            <!-- How many connection objects does the database Connection pool want from the database at one time -->
            <property name="acquireIncrement">20</property>
            <!-- Initialize connections -->
            <property name="initialPoolSize">10</property>
            <!-- Minimum number of connections -->
            <property name="minPoolSize">5</property>
            <!-- The maximum number of connections reserved in the Connection pool. Default: 15 -->
            <property name="maxPoolSize">30</property>
            <!-- JDBC standard parameter used to control the number of PreparedStatements loaded within the data source. However, the pre cached statements belong to a single connection rather than the entire Connection pool. So setting this parameter requires considering multiple factors. If both maxStatements and maxStatementsPerConnection are 0, the cache is turned off. Default:0 -->
            <property name="maxStatements">0</property>
            <!-- MaxStatementsPerConnection defines the maximum number of cached statements owned by a single connection in the Connection pool. Default: 0 -->
            <property name="maxStatementsPerConnection">0</property>
            <!-- C3p0 is an asynchronous operation, and slow JDBC operations are completed by the helper process. Expanding these operations can effectively improve performance by enabling multiple operations to be executed simultaneously through multithreading. Default:3 -->
            <property name="numHelperThreads">3</property>
            <!-- The user can wait up to 300 seconds before modifying the system configuration parameters. Default: 300 -->
            <property name="propertyCycle">3</property>
            <!-- The default setting for obtaining the connection timeout is to wait for a unit of milliseconds -->
            <property name="checkoutTimeout">1000</property>
            <!-- Check all free connections in the Connection pool every few seconds. Default: 0 -->
            <property name="idleConnectionTestPeriod">3</property>
            <!-- The maximum idle time, within seconds, if not used, the connection will be discarded. If it is 0, it will never be discarded. Default: 0 -->
            <property name="maxIdleTime">10</property>
            <!-- Configure the lifetime of the connection. Connections beyond this time will be automatically disconnected and discarded by the Connection pool. Of course, the connection being used will not be immediately disconnected, but will wait for it to close before disconnecting. When configured to 0, there is no restriction on the lifetime of the connection. -->
            <property name="maxIdleTimeExcessConnections">5</property>
            <!-- The interval time between two connections, in milliseconds. Default: 1000 -->
            <property name="acquireRetryDelay">1000</property>
            <!-- C3p0 will create an empty table called Test and use its built-in query statement for testing. If this parameter is defined, the property preferredTestQuery will be ignored. You cannot perform any operations on this Test table, it will only be used for c3p0 testing. Default: null -->
            <property name="automaticTestTable">test</property>
            <!-- Test if the connection is valid when obtaining it -->
            <property name="testConnectionOnCheckin">true</property>
        </named-config>
    </c3p0-config>
    
    package com.example;
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import com.mchange.v2.c3p0.ComboPooledDataSource;
    
    public class Main {
    
        public static void main(String[] args) {
            try (Connection conn = getConnection();
    
                 PreparedStatement stmtCreate = conn.prepareStatement("CREATE TABLE test_c3p0 (id NUMBER, name VARCHAR2(32))");
                 PreparedStatement stmtInsert = conn.prepareStatement("INSERT INTO test_c3p0 VALUES (?, ?)");
                 PreparedStatement stmtDelete = conn.prepareStatement("DELETE FROM test_c3p0 WHERE id < ?");
                 PreparedStatement stmtUpdate = conn.prepareStatement("UPDATE test_c3p0 SET name = ? WHERE id = ?");
                 PreparedStatement stmtSelect = conn.prepareStatement("SELECT * FROM test_c3p0")) {
                
                conn.setAutoCommit(false); 
    
                stmtCreate.execute();
    
                for (int i = 0; i < 10; i++) {
                    stmtInsert.setInt(1, i);
                    stmtInsert.setString(2, "test_insert" + i);
                    stmtInsert.executeUpdate();
                }
    
                stmtDelete.setInt(1, 5);
                stmtDelete.executeUpdate();
    
                stmtUpdate.setString(1, "test_update");
                stmtUpdate.setInt(2, 5);
                stmtUpdate.executeUpdate();
    
                ResultSet rs = stmtSelect.executeQuery();
                while (rs.next()) {
                    System.out.println(rs.getInt("id") + "   " + rs.getString("name"));
                }
                rs.close();
    
                conn.commit(); 
                
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    
        private static Connection getConnection() throws Exception {
            ComboPooledDataSource cpds = new ComboPooledDataSource("oceanbase");
            return cpds.getConnection();
        }
    }
    

    References

    For more information about OceanBase Connector/J, see OceanBase JDBC driver.

    Previous topic

    Sample program that uses a Tomcat connection pool to connect to OceanBase Cloud
    Last

    Next topic

    Connect to OceanBase Cloud using Proxool connection pool
    Next
    What is on this page
    Prerequisites
    Procedure
    Step 1: Import the c3p0-oceanbase-jdbc project into Eclipse
    Step 2: Modify the database connection information in the c3p0-oceanbase-jdbc project
    Step 3: Run the c3p0-oceanbase-jdbc project
    Project code
    Introduction to the pom.xml file
    Introduction to c3p0-config.xml
    Main.java code introduction
    Complete code
    References