This topic describes how to connect to and access OceanBase Database in Oracle 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
You can connect to an Oracle tenant of OceanBase Database by using the following 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 tenant or a MySQL 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 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.
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 mode or Oracle mode, adapting to both at the protocol level.
Notice
OceanBase Database determines whether to run in MySQL or Oracle mode based on the tenant name that is used when the JDBC driver is connected to the database service. Oracle 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 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.