This topic describes how to connect to OceanBase Cloud in the MySQL compatible mode. You can connect to OceanBase Cloud by using a client, a driver, or an Object Relational Mapping (ORM) framework.
Clients
You can connect to a MySQL-compatible tenant of OceanBase Cloud by using any of the following clients:
MySQL client (mysql)
mysql is a MySQL CLI tool that must be separately installed. OceanBase Cloud tenants are categorized into MySQL-compatible tenants and Oracle-compatible tenants. You can use mysql to access a MySQL-compatible tenant.
After you connect to OceanBase Cloud, you can run MySQL O&M commands and execute SQL statements in the CLI of mysql for the following purposes:
Calculate, store, and generate query results
Create database objects and check and modify object definitions
Manage databases and modify parameters
For more information about how to connect to a MySQL-compatible tenant of OceanBase Cloud by using a MySQL client, see Connect to OceanBase Cloud by using a MySQL client.
OceanBase Client (OBClient)
OBClient is an interactive query tool that supports batch processing. It must be installed separately. OBClient provides a CLI and acts as the client when it is connected to OceanBase Cloud. It supports Oracle-compatible and MySQL-compatible tenants of OceanBase Cloud.
Before you use OBClient to connect to an OceanBase Cloud tenant, you must specify the connection information of the tenant. After you connect to OceanBase Cloud, you can use OBClient to run some database commands (including general MySQL commands) and execute some SQL and PL/SQL statements for the following purposes:
Calculate, store, and generate query results
Create database objects and check and modify object definitions
Develop and run batch scripts
Manage databases and modify parameters
For more information about how to connect to OceanBase Cloud by using OBClient, see Connect to OceanBase Cloud by using OBClient.
OceanBase Developer Center (ODC)
ODC is an enterprise-level database development platform tailored for OceanBase Cloud.
ODC is compatible with both MySQL-compatible and Oracle-compatible tenants of OceanBase Cloud. It provides database developers with various features, such as daily development, WebSQL-based workspace, SQL diagnostics, session management, and data import and export.
For more information about how to connect to OceanBase Cloud by using ODC, see Connect to OceanBase Cloud by using Client ODC.
Drivers
You can connect to a MySQL-compatible tenant of OceanBase Cloud by using any of the following drivers:
Java driver (MySQL Connector/J)
MySQL Connector/J is a Java Database Connectivity (JDBC) driver provided by MySQL.
Note
To ensure your experience with OceanBase Cloud, we recommend that you use MySQL Connector/J of the following versions:
- For MySQL Connector/J 5.x, versions 5.1.40 to 5.1.49 are recommended.
- For MySQL Connector/J 8.x, versions 8.0.7 to 8.0.25 and versions 8.2.0 to 8.4.0 are recommended.
For more information about how to connect Java applications to OceanBase Cloud, see Connect to OceanBase Cloud by using MySQL Connector/J.
C driver (OceanBase Connector/C)
OceanBase Connector/C is an OBClient development component based on C/C++. OceanBase Connector/C supports C API libraries.
OceanBase Connector/C allows C/C++ applications to access distributed OceanBase clusters from the underlying layer. Then, the applications can perform operations such as database connection, data access, error processing, and prepared statement processing.
OceanBase Connector/C is also called LibOBClient. By using OceanBase Connector/C, an application can act as an independent server process to communicate with OBServer nodes over network connections. A client application references the C API header file during compilation and can link to the C API library file.
Note
The
.sofile generated by LibOBClient islibobclient.so, which corresponds to thelibmysqlclient.sofile in MySQL. OceanBase Cloud uses OBClient as its CLI tool, which corresponds to the CLI tool in MySQL.For more information about how to connect C applications to OceanBase Cloud, see Connect to OceanBase Cloud by using MySQL Connector/C.
Python driver (PyMySQL)
If you use Python 3.x, you can connect to a MySQL database server by using PyMySQL. PyMySQL follows the Python Database API Specification 2.0 and contains a pure-Python MySQL client library. In the MySQL compatible mode of OceanBase Cloud, you can use PyMySQL to connect Python applications to OceanBase Cloud.
For more information about how to connect Python applications to OceanBase Cloud, see Connect to OceanBase Cloud by using PyMySQL.
ORM frameworks
ORM is a programming technique that converts data between different types of systems by using object-oriented programming languages. In effect, ORM creates a "virtual object database" that can be used within programming languages.
You can connect to a MySQL-compatible tenant of OceanBase Cloud by using any of the following ORM frameworks:
Spring Boot
For more information about how to connect to OceanBase Cloud by using Spring Boot, see Connect to OceanBase Cloud by using Spring Boot.
Spring Batch
For more information about how to connect to OceanBase Cloud by using Spring Batch, see Connect to OceanBase Cloud by using Spring Batch.
Spring Data JDBC
For more information about how to connect to OceanBase Cloud by using Spring Data JDBC, see Connect to OceanBase Cloud by using Spring Data JDBC.
Spring Data JPA
For more information about how to connect to OceanBase Cloud by using Spring Data JPA, see Connect to OceanBase Cloud by using Spring Data JPA.
Hibernate
For more information about how to connect to OceanBase Cloud by using Hibernate, see Connect to OceanBase Cloud by using Hibernate.
MyBatis
For more information about how to connect to OceanBase Cloud by using MyBatis, see Connect to OceanBase Cloud by using MyBatis.