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 the query results
Create database objects, check and modify object definitions
Develop and run batch processing scripts
Manage the database 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 provides database developers with various features, including daily 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 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 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 can link with this library at runtime to use these features.
OceanBase provides OBCI, which is a C language calling interface for OceanBase Database that is compatible with OCI. Applications written in C using OCI can be directly used with OBCI without modification, as long as the runtime library is changed to the OBCI library. 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 a C application 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 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) provides APIs for connecting Java applications to relational databases. It is a Java standard defined by Sun Microsystems. JDBC implements the standard
java.sqlinterface and allows third-party providers to implement their own JDBC drivers to realize and extend the standard. 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 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 the running mode is MySQL or Oracle. It is also protocol-compatible with both modes.
Notice
OceanBase Database determines the running mode, MySQL or Oracle, based on the tenant name when a JDBC driver is connected. 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. As a result, OceanBase Database in Oracle mode is compatible with most SQL syntaxes in Oracle.
OceanBase Connector/J is installed with one click. The name of the installation package is:
oceanbase-client-[version].jar.Download OceanBase Connector/J. On the Resources > Download Center > Enterprise Edition > Drivers and Middleware page of OceanBase Database, click OceanBase JDBC Driver to go to the download page. Choose the appropriate version, fill in the request information, and download the OceanBase Connector/J installation package. 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 a Java application 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 framework
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.