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 Oracle and MySQL tenants in OceanBase Database.
Before running OBClient, you must 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 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, 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 provides database developers with various features, including daily development, WebSQL-based workspace, SQL diagnostics, session management, and data import and export.
For more information, see Connect to an OceanBase tenant by using ODC.
Connect to OceanBase Database by using a driver or an ORM framework
C
C driver
OBCI
OceanBase Call Interface (OBCI) is a C language interface for OceanBase Database that is 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. OBCI 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 language calling interface compatible with OCI, to offer features compatible with OCI. C language applications written with Oracle OCI can be directly deployed using OBCI without modifying the source code. The OBCI library is installed by default to the
/u01/obclient/libdirectory.For more information about how to connect C applications to OceanBase Database, see Connect C applications to OceanBase Database.
ODBC
Open Database Connectivity (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 for OceanBase Database allows applications to use standard SQL syntax to interact with OceanBase Database without concerning themselves with 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. By using the ODBC driver, developers can easily connect to OceanBase in various environments, simplify the data access process, and increase their development efficiency.
For more information about how to connect to OceanBase Database by using ODBC, see Connect C applications 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 C applications 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 an API that allows Java applications to connect to relational databases. It is a Java standard defined by Sun Microsystems. JDBC implements the standard
java.sqlinterface and supports various providers in implementing and extending the standard using their own JDBC drivers. JDBC is a call-level interface (CLI) based on the X/Open SQL standard.OceanBase Connector/J is a JDBC Type 4 driver that communicates directly with the database engine using 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 compatible with MySQL JDBC drivers and can automatically identify whether the OceanBase Database is operating in MySQL or Oracle mode. It is protocol-compatible with both modes.
Notice
OceanBase Database determines the operating mode, MySQL or Oracle, based on the tenant name of the JDBC driver that is connected to. Only SQL syntaxes compatible with Oracle are supported in Oracle mode.
In addition to standard Java Database Connectivity (JDBC) application programming interfaces (APIs), OceanBase Connector/J also supports APIs in Oracle drivers. Therefore, OceanBase Database in Oracle mode is compatible with most syntaxes in Oracle.
OceanBase Connector/J uses a one-click installation mode. The driver package name is:
oceanbase-client-[version].jar.Download the OceanBase Connector/J driver package from OceanBase JDBC driver on the Resources > Download Center > Enterprise Edition > Drivers and Middleware page of OceanBase Database. For more information, see the OceanBase Connector/J chapter on the OceanBase Database website.
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 using SpringJDBC, see Connect to OceanBase Database using SpringJDBC.
Java ORM framework
SpringBoot
For more information about how to connect to OceanBase Database using SpringBoot, see Connect to OceanBase Database using SpringBoot.
SpringBatch
For more information about how to connect to OceanBase Database using SpringBatch, see Connect to OceanBase Database using SpringBatch.
SpringJPA
For more information about how to connect to OceanBase Database using SpringJPA, see Connect to OceanBase Database using SpringJPA.
Hibernate
For more information about how to connect to OceanBase Database using Hibernate, see Connect to OceanBase Database using Hibernate.
MyBatis
For more information about how to connect to OceanBase Database using MyBatis, see Connect to OceanBase Database using MyBatis.
Jfinal
For more information about how to connect to OceanBase Database using Jfinal, see Connect to OceanBase Database using MyBatis.
Connection pools
OceanBase Database supports multiple connection pool implementations. You can select a connection pool implementation that suits your business characteristics.
