This topic describes how to connect to MySQL tenants of OceanBase Database. Currently, you can connect to OceanBase Database by using a client, a driver, or an Object Relational Mapping (ORM) framework.
Connect to OceanBase Database by using a client
You can connect to a MySQL tenant of OceanBase Database by using any of the following clients:
MySQL client (mysql)
The mysql client is a MySQL command-line interface (CLI) tool. It must be separately installed. OceanBase Database supports MySQL tenants and Oracle tenants. You can use the mysql client to access a MySQL tenant.
After you connect to OceanBase Database, you can run MySQL O&M commands and execute SQL statements on the CLI of the mysql client for the following purposes:
Calculating, storing, and generating query results
Creating database objects, checking and modifying object definitions
Managing databases and modifying parameters
For more information about how to connect to a MySQL tenant of OceanBase Database by using the mysql client, see Connect to an OceanBase tenant by using the mysql 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 Database. It supports both MySQL and Oracle tenants of OceanBase Database.
Before you use OBClient to connect to an OceanBase tenant, you must specify the connection information of the tenant. After you connect to OceanBase Database, 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:
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.
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 of OceanBase Database. 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 an OceanBase tenant by using ODC, see Connect to OceanBase Database by using ODC.
Connect to OceanBase Database by using a driver
You can connect to a MySQL tenant of OceanBase Database 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 Database, 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 Database, see Build a Java application.
C driver (OceanBase Connector/C)
OceanBase Connector/C is a development component based on C/C++ for OceanBase Database. It 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 handling, and prepared statement processing.
OceanBase Connector/C, also known as LibOBClient, is used by applications as an independent server process to communicate with OBServer nodes through network connections. Applications reference the C API header files during compilation and can connect to the C API library file.
Note
The
.sofile generated by LibOBClient islibobclient.so, which corresponds to thelibmysqlclient.sofile in MySQL. OceanBase Database 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 Database, see Build a C application.
Python driver (PyMySQL)
If you use Python 3.x, you can connect to a MySQL database server by using PyMySQL. PyMySQL implements Python Database API Specification 2.0 and contains a pure-Python MySQL client library. In the MySQL mode of OceanBase Database, you can use PyMySQL to connect Python applications to OceanBase Database.
For more information about how to connect Python applications to OceanBase Database, see Build a Python application.
Connect to OceanBase Database by using an ORM framework
ORM is a programming technique for data conversion between a relational database and an object-oriented programming language. This creates, in effect, a "virtual object database" that can be used from within the programming language.
You can connect to a MySQL tenant of OceanBase Database by using any of the following ORM frameworks:
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 JDBC
For more information about how to connect to OceanBase Database by using Spring JDBC, see Connect to OceanBase Database by using Spring JDBC.
Spring Data JPA
For more information about how to connect to OceanBase Database by using Spring Data JPA, see Connect to OceanBase Database by using Spring Data 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.