This topic describes how to connect to and access OceanBase Database in Oracle mode. Currently, you can connect to OceanBase Database using an Oracle client, an Oracle driver, an ORM framework, or a connection pool.
Connect to OceanBase Database
When you connect to an Oracle tenant of OceanBase Database, the following clients are supported:
OceanBase Client (OBClient)
OBClient is an interactive query tool that supports batch processing. It must be installed separately. OBClient provides a command-line interface and can be used as the client in a database connection. It supports both Oracle and MySQL tenants in OceanBase Database.
Before OBClient runs, you need to specify the connection information of the OceanBase tenant. After you connect to OceanBase Database, you can use OBClient to run some database commands (including general MySQL commands) and execute SQL and PL/SQL statements to accomplish the following tasks:
Calculate, store, and print query results
Create database objects, verify and modify object definitions
Develop and run batch processing scripts
Manage databases and modify parameters
For more information about how to connect to an OceanBase tenant by using OceanBase Client, see Connect to an OceanBase tenant by using OBClient.
OceanBase Developer Center (ODC)
OceanBase Developer Center (ODC) is an enterprise-level database development platform tailored for OceanBase Database.
ODC is compatible with both MySQL and Oracle tenants in OceanBase Database. It offers features such as database development, WebSQL-based workspace, SQL diagnostics, session management, and data import and export.
For more information about how to connect to an OceanBase tenant by using ODC, see Connect to OceanBase Database by using ODC.
Connect to OceanBase Database using a driver or an ORM framework
C
C driver
OBCI
OceanBase Call Interface (OBCI) is a C language interface compatible with Oracle Call Interface (OCI). OBCI provides features fully compatible with OCI.
With OBCI, you can use the C language to operate data in OceanBase Database. It provides standard database access features in the form of a dynamic-linked library (OBCI library). Applications link with this library at runtime to use these features.
OceanBase provides OBCI, a C calling interface compatible with Oracle OCI, to offer features compatible with OCI. If you write a C language application using Oracle OCI, you need only replace OCI with OBCI in the linking stage. The default installation path of this library is
/u01/obclient/lib.For more information about how to connect C applications to OceanBase Database, see Connect a C application to OceanBase Database.
ODBC
Open Database Connectivity (ODBC) is a standard database access interface. It allows you to connect to and operate different types of databases in a unified way. The ODBC driver provided by OceanBase allows applications to use standard SQL syntax to interact with OceanBase Database, without revealing the underlying implementation details. With ODBC, you can develop applications in multiple programming languages (such as C and C++) and achieve compatibility and flexibility across databases. You can easily connect to OceanBase in various environments, simplify the data access process, and increase your development efficiency by using the ODBC driver.
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 concise and easy-to-use C# ORM (Object-Relational Mapping) framework designed to help developers perform database operations quickly and efficiently. SqlSugar provides powerful data querying and manipulation capabilities, supporting various mainstream databases, including OceanBase. With SqlSugar, developers can execute complex database operations using simple C# code, avoiding the hassle of writing cumbersome SQL statements, thus 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 Java applications to connect to OceanBase Database. It uses the standard Java Database Connectivity (JDBC) API.
Java Database Connectivity (JDBC) is a Java standard that provides interfaces for connecting Java applications to relational databases. JDBC is defined by Sun Microsystems and implemented through the standard
java.sqlinterface. It allows third-party providers to implement and extend the standard through their own JDBC drivers. JDBC is a call-level interface (CLI) based on X/Open SQL.OceanBase Connector/J is a JDBC Type 4 driver that communicates directly with the database engine through a local protocol. It is compatible with the OB2.0 protocol.
OceanBase Database supports OceanBase Connector/J, and is fully compatible with native JDBC drivers for MySQL (MySQL Connector Java). OceanBase Connector/J is fully compatible with MySQL JDBC drivers and can automatically identify whether OceanBase Database is operating in MySQL or Oracle mode. It is also protocol-compatible with both modes.
Notice
OceanBase Database identifies the operating mode as MySQL or Oracle based on the tenant name of the JDBC driver. In Oracle mode, only SQL syntaxes compatible with Oracle are supported by the tenant.
In addition to supporting standard Java Database Connectivity (JDBC) application programming interfaces (APIs), OceanBase Connector/J also supports APIs used in Oracle drivers. As a result, OceanBase Database in Oracle mode is compatible with most SQL syntaxes in Oracle.
OceanBase Connector/J uses a one-click installation mode. The driver installation package name is:
oceanbase-client-[version].jar.Download the OceanBase Connector/J driver. On the Resources > Download Center > Enterprise Edition > Drivers and Middleware page of OceanBase Database's official website, click OceanBase JDBC driver to download the installation package of OceanBase Connector/J. For more information about the installation steps, see OceanBase Connector/J.
For more information about how to connect Java applications to OceanBase Database, see Connect Java applications to OceanBase Database.
SpringJDBC
For more information about how to connect to OceanBase Database by using SpringJDBC, see Connect to OceanBase Database by using SpringJDBC.
Java ORM frameworks
SpringBoot
For more information about how to connect to OceanBase Database by using SpringBoot, see Connect to OceanBase Database by using SpringBoot.
SpringBatch
For more information about how to connect to OceanBase Database by using SpringBatch, see Connect to OceanBase Database by using SpringBatch.
SpringJPA
For more information about how to connect to OceanBase Database by using SpringJPA, see Connect to OceanBase Database by using SpringJPA.
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 a suitable connection pool implementation based on your business characteristics.