This topic describes how to connect to and access OceanBase Database's Oracle-compatible mode. Currently, you can connect to OceanBase Database by using a client, driver, Object Relational Mapping (ORM) framework, or connection pool.
Connect to OceanBase Database by using a client
When connecting to an Oracle-compatible tenant of OceanBase Database, you can use the following CLI clients:
OceanBase Client (OBClient)
OBClient is an interactive query tool that supports batch processing and requires separate installation. It provides a CLI and serves as a client for connecting to either an Oracle-compatible tenant or a MySQL-compatible tenant in OceanBase Database.
Before using OBClient to connect to an OceanBase tenant, you need to provide the tenant's connection details. Once connected to OceanBase Database, OBClient allows you to execute various database commands, including standard MySQL commands as well as SQL and PL/SQL statements, for the following purposes:
Calculating, storing, and generating query results
Creating database objects, checking and modifying object definitions
Developing and running batch processing scripts
Managing databases and modifying parameters
For more information about how to connect to an OceanBase tenant by using OBClient, see Connect to an OceanBase tenant by using OBClient.
OceanBase Developer Center (ODC)
ODC is an enterprise-level database development platform tailored for OceanBase Database.
ODC supports connections to both MySQL- and Oracle-compatible tenants within OceanBase Database. It offers a range of features for database developers, including routine development tasks, WebSQL, SQL diagnostics, session management, and data import/export capabilities.
For more information about how to connect to an OceanBase tenant by using ODC, see Connect to OceanBase Database by using ODC.
GUI database management tools
In addition to CLI tools, you can use the following GUI tools to connect to and manage OceanBase Database:
DBeaver
DBeaver is a universal database client that supports connecting to an Oracle-compatible tenant of OceanBase Database through the Oracle driver. It provides an intuitive GUI and supports SQL editing, data browsing, table design, and other features.
For more information about how to connect to OceanBase Database by using DBeaver, see Connect to OceanBase Database by using DBeaver.
Navicat
Navicat is a powerful database management tool that supports connecting to an Oracle-compatible tenant of OceanBase Database through the Oracle driver. It provides data visualization, data synchronization, report generation, and other features.
For more information about how to connect to OceanBase Database by using Navicat, see Connect to OceanBase Database by using Navicat.
Connect to OceanBase Database by using a driver or an ORM framework
C
C driver
OceanBase Call Interface (OBCI)
OBCI is a C language interface that is compatible with Oracle Call Interface (OCI). It offers features that are fully compatible with those of OCI.
With OBCI, you can use the C language to manage data in the OceanBase Database. It provides standard database access functionality through a dynamically linked library (OBCI library). Applications can access these features by linking to this library at runtime.
OceanBase's OBCI is a C language call interface compatible with OCI, offering the same features as OCI. When developing C language applications using Oracle OCI, you do not need to modify the application's source code. Simply specify the OBCI library as the runtime library during the linking process. By default, this library is installed in the
/u01/obclient/libdirectory.For more information about how to connect to OceanBase Database by using a C application, see Connect a C application to OceanBase Database.
Open Database Connectivity (ODBC)
ODBC is a standard database access interface that allows you to connect to and operate different types of databases in a unified way. The ODBC driver provided by OceanBase Database enables applications to interact with OceanBase Database using standard SQL syntax, without needing to worry about the underlying implementation details. With ODBC, you can develop applications in various programming languages (such as C, C++, and Python), achieving cross-database compatibility and flexibility. By using the ODBC driver, developers can easily connect to OceanBase Database in various environments, simplifying the data access process and improving development efficiency.
For more information about how to connect to OceanBase Database by using ODBC, see Connect a C application to OceanBase Database.
C ORM framework
SqlSugar
SqlSugar is a simple and easy-to-use C# ORM framework designed to help developers perform database operations quickly and efficiently. SqlSugar provides powerful data querying and manipulation capabilities and supports various mainstream databases, including OceanBase Database. With SqlSugar, developers can execute complex database operations using straightforward C# code, avoiding the need to write cumbersome SQL statements and significantly improving development efficiency.
For more information about how to connect to OceanBase Database by using SqlSugar, see Connect a C application to OceanBase Database.
Java
Java driver
OceanBase Connector/J
OceanBase Connector/J provides a driver for connecting Java applications to the OceanBase Database using standard Java Database Connectivity (JDBC) APIs.
JDBC is a Java standard defined by Sun Microsystems that provides APIs for connecting Java applications to relational databases. It implements the standard
java.sqlAPI, allowing providers to create their own JDBC drivers and extend the standard. JDBC is based on the Call Level Interface (CLI) of X/Open SQL.OceanBase Connector/J is a JDBC Type 4 driver that communicates directly with the database engine via a local protocol. It is fully compatible with the OB2.0 protocol.
OceanBase Database supports the OceanBase Connector/J driver and is also fully compatible with MySQL's native JDBC driver (MySQL Connector Java). OceanBase Connector/J seamlessly supports MySQL JDBC usage patterns and can automatically detect whether OceanBase Database is running in MySQL-compatible mode or Oracle-compatible mode, adapting to both at the protocol level.
Notice
OceanBase Database determines whether to run in MySQL- or Oracle-compatible mode based on the tenant name that is used when the JDBC driver is connected to the database service. Oracle-compatible tenants can use only Oracle-compatible SQL syntax.
In addition to supporting the standard JDBC application programming interface (API), OceanBase Connector/J is also compatible with the usage patterns of the Oracle Driver. OceanBase's Oracle-compatible mode is compatible with most of Oracle's syntax.
OceanBase Connector/J is installed in one click. The name of the installation package is
oceanbase-client-[version].jar.To obtain the installation package of OceanBase Connector/J, go to OceanBase Download Center. For more information about the installation procedure, see OceanBase Connector/J.
For more information about how to connect Java applications to OceanBase Database, see Connect a Java application to OceanBase Database.
Spring JDBC
For more information about how to connect to OceanBase Database by using Spring JDBC, see Connect to OceanBase Database by using Spring JDBC.
Java ORM framework
Spring Boot
For more information about how to connect to OceanBase Database by using Spring Boot, see Connect to OceanBase Database by using Spring Boot.
Spring Batch
For more information about how to connect to OceanBase Database by using Spring Batch, see Connect to OceanBase Database by using Spring Batch.
Spring JPA
For more information about how to connect to OceanBase Database by using Spring JPA, see Connect to OceanBase Database by using Spring JPA.
Hibernate
For more information about how to connect to OceanBase Database by using Hibernate, see Connect to OceanBase Database by using Hibernate.
MyBatis
For more information about how to connect to OceanBase Database by using MyBatis, see Connect to OceanBase Database by using MyBatis.
Jfinal
For more information about how to connect to OceanBase Database by using Jfinal, see Connect to OceanBase Database by using MyBatis.
Connection pools
OceanBase Database supports multiple connection pool implementations. You can select the one that best suits your business requirements. The following table describes the characteristics and use cases of each connection pool:
| Connection pool | Characteristics | Use case |
|---|---|---|
| Druid | Feature-rich, provides monitoring and statistics | Enterprise applications that require connection pool monitoring and management |
| HikariCP | High performance, lightweight | High-concurrency applications that require high performance |
| C3P0 | Mature and stable, feature-rich | Traditional Java applications |
| DBCP | Apache project, flexible configuration | Integration with Spring and other frameworks |
| Proxool | Supports connection pool monitoring | Applications that require connection status monitoring |
| Tomcat | Built into the Tomcat container | Web applications |
| Commons Pool | General-purpose object pool implementation | Custom connection pool logic |
Connection pool configuration recommendations
- Initial connections: Set to 5-10
- Maximum connections: Set based on application load and database resources
- Connection timeout: Set to 30 seconds
- Idle connection eviction time: Set to 10 minutes
- Validation query: Set to
SELECT 1 FROM DUAL
Monitoring and maintenance
- Regularly check the connection pool status to avoid connection leaks
- Monitor connection wait time and active connection count
- Adjust connection pool parameters dynamically based on business load
Connection pool implementation examples
OceanBase Database supports the following connection pool implementations. Click to view detailed configuration examples: