Connection methods overview
This topic describes how to connect to a MySQL tenant of an OceanBase database. OceanBase Database supports connections using clients, drivers, and Object Relational Mapping (ORM) frameworks.
Client
The following clients are supported for connecting to a MySQL tenant of an OceanBase database:
MySQL client
A command line client for MySQL databases that requires a separate installation.
NoteAn OceanBase database tenant can be a MySQL tenant or an Oracle tenant. The MySQL client can only access MySQL tenants.
After you connect to an OceanBase database, you can run MySQL O&M commands and SQL statements in the MySQL client command line environment to perform the following tasks:
Calculate, store, and print query results.
Create database objects, and check and modify object definitions.
Perform database management and modify parameters.
For an example of how to connect to an OceanBase tenant using the MySQL client, see Connect to an OceanBase tenant using the MySQL client.
OceanBase client (OBClient)
OBClient is a command line interface for interactive and batch queries. It supports both MySQL and Oracle tenants of OceanBase Database. You can download and install it from the Software Center.
You must specify the connection information for the OceanBase database tenant when you run OBClient. After you connect to the OceanBase database, you can run database commands (including common MySQL commands), SQL statements, and PL statements in OBClient to perform the following tasks:
Calculate, store, and print query results.
Create database objects, and check and modify object definitions.
Develop and run batch scripts.
Perform database management and modify parameters.
For an example of how to connect to an OceanBase tenant using OBClient, see Connect to an OceanBase tenant using OBClient.
OceanBase Developer Center (ODC)
OceanBase Developer Center (ODC) is an enterprise-grade database development platform designed for OceanBase Database. You can access and use ODC from the OceanBase console.
ODC supports connections to both MySQL and Oracle tenants of OceanBase Database. It also provides database developers with features such as daily database development operations, WebSQL, SQL diagnostics, session management, and data import and export.
For an example of how to connect to an OceanBase database using ODC, see Connect to an OceanBase database using ODC.
Drivers
The following drivers are supported for connecting to a MySQL tenant of an OceanBase database:
Java driver (MySQL Connector/J)
MySQL Connector/J is the official Java Database Connectivity (JDBC) driver from MySQL.
For an example of how to connect to an OceanBase database using a Java driver, see Connect to an OceanBase database using a Java driver.
C driver (OceanBase Connector/C)
OceanBase Connector/C is a C/C++-based client development component for OceanBase that supports the C API Lib library.
OceanBase Connector/C allows C/C++ programs to access an OceanBase distributed database cluster at a low level to perform operations such as establishing database connections, accessing data, handling faults, and processing Prepared Statements.
OceanBase Connector/C is also known as LibOBClient. Applications use it as an independent server process to communicate with OBServer nodes over a network connection. Client programs reference C API header files at compile-time and can link to the C API library file.
NoteThe .so file generated by LibOBClient is
libobclient.so(corresponding to MySQL'slibmysqlclient.so). The command line interface installed with OceanBase Database is OBClient (corresponding to the MySQL command line interface).For an example of how to connect to an OceanBase database using a C driver, see Connect to an OceanBase database using a C driver.
Python driver
PyMySQL is a library for connecting to MySQL servers in Python 3.x. It follows the Python Database API Specification v2.0 and includes a pure-Python MySQL client library. For OceanBase databases in MySQL mode, you can use the PyMySQL driver to connect your Python application.
For Python 2.x, you can use the MySQL-python driver to connect to an OceanBase database.
For an example of how to connect to an OceanBase database using a Python driver, see Connect to an OceanBase database using a Python driver.
Go driver
Go MySQL Driver is a driver that wraps the
database/sql/driverinterface in the Go language. You can simply import this driver to use the fulldatabase/sqlAPI.For an example of how to connect to an OceanBase database using a Go driver, see Connect to an OceanBase database using a Go driver.
ORM frameworks
Object Relational Mapping (ORM) is a programming technique used to convert data between incompatible type systems in object-oriented programming languages. In effect, it creates a "virtual object database" that can be used from within the programming language.
When you connect to a MySQL tenant of an OceanBase database, you can refer to the following documents for information about how to use JDBC-based ORM frameworks: