GaussDB Application Development Guide
You can connect to and perform operations on a database through APIs such as JDBC, ODBC, libpq, Psycopg, Go, and ecpg.
JDBC
Java Database Connectivity (JDBC) is a Java API for running SQL statements. It provides unified access APIs for different relational databases. It allows Java applications to use SQL statements to perform database operations, such as querying, inserting, updating, and deleting data.
Some key features and usage of JDBC are as follows:
- Database connection management: JDBC allows applications to establish connections to databases and manages the lifecycle of these connections.
- SQL execution: JDBC can be used to query, update, and delete SQL statements. This is achieved by constructing SQL statements in Java code and sending them to the database.
- Transaction management: JDBC APIs can be used to start, commit, or roll back transactions to ensure the consistency and integrity of database operations.
- Exception handling: JDBC defines a group of exception classes to handle various exceptions that may occur during database operations. Developers can use the try-catch block to capture and handle these exceptions.
- Batch processing: JDBC provides the batch processing function, which allows multiple SQL statements to be executed concurrently, improving the efficiency of database operations.
- Metadata access: JDBC can be used to obtain the metadata information of the database, such as the table structure, column name, and data type. Developers then can dynamically construct SQL query statements or perform operations based on the database structure.
In conclusion, JDBC provides a flexible and powerful bridge that enables Java applications to interact with various databases and to implement data persistence and management. GaussDB supports JDBC 4.0 and requires JDK 1.8 for code compiling. It does not support JDBC-ODBC bridging.
For details about JDBC-based development, see Development Based on JDBC.
ODBC
Open Database Connectivity (ODBC) is a Microsoft API for accessing databases in C/C++ based on the X/OPEN CLI. It provides a unified method for applications to access various database management systems (DBMSs) without considering specific database types or OS platforms. ODBC allows applications to use SQL to query, insert, update, and delete data in a database. Applications interact with the database through the APIs provided by ODBC, which enhances their portability, scalability, and maintainability.
The ODBC architecture consists of three main components: application, ODBC driver manager, and ODBC driver. Applications use ODBC APIs to communicate with the ODBC driver manager which loads and manages ODBC drivers. The ODBC drivers are responsible for communicating with a specific database, executing SQL queries, and returning results. Figure 1 shows the system structure of ODBC.
In conclusion, ODBC provides a flexible and cross-platform method that allows users to easily connect applications to various databases without worrying about the details of a specific database system.
For details about ODBC-based development, see Development Based on ODBC.
GaussDB supports ODBC in the following environments.
OS |
Platform |
---|---|
CentOS 6.4/6.5/6.6/6.7/6.8/6.9/7.0/7.1/7.2/7.3/7.4 |
x86_64 |
CentOS 7.6 |
Arm64 |
EulerOS 2.0 SP2/SP3 |
x86_64 |
EulerOS 2.0 SP8 |
Arm64 |
Kylin V10 |
x86_64 |
Kylin V10 |
Arm64 |
The ODBC Driver Manager running on Unix or Linux can be unixODBC or iODBC. unixODBC-2.3.7 is used as the component for connecting to the database.
Windows has a native ODBC Driver Manager. You can locate Data Sources (ODBC) by choosing
.
The current database ODBC driver is based on an open-source version and may be incompatible with data types tinyint, smalldatetime, nvarchar, and nvarchar2.
ODBC limitations:
- ODBC does not support read on standby.
- ODBC does not support user-defined types and does not support user-defined parameters in stored procedures.
- ODBC does not support DR failover.
- When the proc_outparam_override parameter is enabled for the database, ODBC cannot properly call the stored procedure that contains the out parameter.
libpq
libpq is a GaussDB C API. libpq contains a set of library functions that allow client programs to send query requests to the GaussDB servers and obtain query results. It is also the underlying engine of other GaussDB APIs, such as ODBC.
For details about libpq-based development, see Development Based on libpq.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot