openGauss is an open source relational database management system. It has multi-core high-performance, full link security, intelligent operation and maintenance for enterprise features. openGauss, which is early originated from PostgreSQL, integrates Huawei's core experience in database field for many years. It optimizes the architecture, transaction, storage engine, optimizer and ARM architecture. At the meantime, openGauss as a global database open source community, aims to further advance the development and enrichment of the database software/hardware application ecosystem.
Java Database Connectivity (JDBC) is an application programming interface (API) for the programming language Java, which defines how a client may access a database. It is a Java-based data access technology used for Java database connectivity. It provides methods to query and update data in a database, and is oriented toward relational databases. openGauss-connector-jdbc is to provide users with access to the database through the Java language application interface . Users can use the jar package provided by the openGauss official website or build their own jar package to operate the database using JDBC.
Before using the openGauss JDBC driver, make sure your server is up and running with the openGauss database (refer to the openGauss Quickstart)。
Java developers can get jar packages directly from the maven central repository with the following coordinates:
<groupId>org.opengauss</groupId>
<artifactId>opengauss-jdbc</artifactId>
Download the installation package from the official website.
Click on link and under the openGauss Connectors section, select the download button for JDBC_\${version} according to the corresponding system of the server where you are deploying the database. \${version} is the version number you need.
Decompress the zip file.
tar -zxvf openGauss-${version}-JDBC.tar.gz
After unpacking, you can see two jar packages in the same directory, opengauss-jdbc-\${version}.jar and postgresql.jar. opengauss-jdbc-\${version}.jar is a package that can coexist with PG-JDBC, the package name is changed from 2.0.1 to org.postgresql.jar. postgresql to org.opengauss, and the driver name is replaced from jdbc:postgresql:// to jdbc:opengauss://. This is the same package that is currently available from the maven central repository.
To install the driver, the postgresql.jar file has to be in the classpath.
ie: under LINUX/SOLARIS (the example here is my linux box):
export CLASSPATH=.:/usr/local/pgsql/share/java/postgresql.jar
or
export CLASSPATH=.:/usr/local/pgsql/share/java/opengauss-jdbc-${version}.jar
The openGauss JDBC driver currently offers 3 ways to build. One is to build via the one-click script build.sh. The second is a step-by-step build via script. The third is to build via the mvn command.
This will compile the correct driver for your JVM, and build a .jar file (Java ARchive) called postgresql.jar and opengauss-jdbc--\${version}.jar in output/, and you can get openGauss-\${version}-jdbc.tar.gz too.
Notice: postgresql.jar is conflict use with postgres database. Because all class was in package org.postgresql. opengauss-jdbc-\${version}.jar is compatibility with postgres database, all java package renamed org.opengauss
, and jdbc driver is: jdbc:opengauss:/
Remember: Once you have compiled the driver, it will work on ALL platforms that support that version of the API. You don't need to build it for each platform.
The openGauss JDBC driver is generated to support the following operating systems:
The following table lists the software requirements for compiling the openGauss-connector-jdbc.
You are advised to use the default installation packages of the following dependent software in the listed OS installation CD-ROMs or sources. If the following software does not exist, refer to the recommended versions of the software.
Software dependency requirements are as follows:
Software and Environment Requirements | Recommended Version |
---|---|
maven | 3.6.1 |
java | 1.8 |
Git Bash (Windows) | - |
You can download openGauss-connector-jdbc from open source community.
git clone https://gitee.com/opengauss/openGauss-connector-jdbc.git
Now we have completed openGauss-connector-jdbc code. For example, we store it in following directories.
The build.sh in the openGauss-connector-jdbc directory is an important scripting tool for the compilation process. This tool allows for quick code compilation and packaging.
so you can compile the openGauss-connector-jdbc by one command with build.sh. In build.sh, maven and java8 will be installed automatically and use to build target.
Execute the following command to get to the code directory:
[user@linux sda]$ cd /sda/openGauss-connector-jdbc
Execute the following command to package using build.sh:
[user@linux openGauss-connector-jdbc]$ sh build.sh
When finished, the following will be displayed to indicate successful packaging:
Successfully make postgresql.jar
Successfully make opengauss-jdbc-${version} jar package
packaging jdbc...
Successfully make jdbc jar package in openGauss-${version}-${platform}-${bit}-Jdbc.tar.gz
clean up temporary directory!
now, all packages has finished!!
After successful compilation, two jar packages will appear, opengauss-jdbc-${version}.jar and postgresql.jar. compiled jar package path is:/sda/openGauss-connector-jdbc/output.
Prepare the Java and Maven environments.
Execute the following command to get to the code directory:
[user@linux sda]$ cd /sda/openGauss-connector-jdbc
Execute the mvn command:
[user@linux openGauss-connector-jdbc]$ mvn clean install -Dgpg.skip -Dmaven.test.skip=true
A successful build on a Linux system will display the following result:
[INFO] Reactor Summary:
[INFO]
[INFO] openGauss JDBC Driver ............................. SUCCESS [5.344s]
[INFO] PostgreSQL JDBC Driver aggregate .................. SUCCESS [0.004s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.439s
[INFO] Finished at: Tue Aug 31 21:55:01 EDT 2021
[INFO] Final Memory: 44M/1763M
[INFO] ------------------------------------------------------------------------
Two jar packages will appear after a successful build, opengauss-jdbc-\${version}.jar and postgresql.jar. jar package path is /sda/openGauss-connector-jdbc/pgjdbc /target/. notice: this build artifact's package name is org.postgresql which different with maven central repository. if you want build package with org.opengauss, please refer to build.sh.
Reference JDBC-based development.
For more details about the installation guide, tutorials, and APIs, please see the User Documentation.
Check out how openGauss implements open governance works.
#opengauss-meeting
(only for meeting minutes logging purpose)Welcome contributions. See our Contributor for more details.
For the release notes, see our RELEASE.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. Open source ecosystem
2. Collaboration, People, Software
3. Evaluation model