JDBC Package, Driver Class, and Environment Class
JDBC Package
Run build.sh in the source code directory on Linux OS to obtain the driver JAR package postgresql.jar, which is stored in the source code directory. Obtain the package from the release package named openGauss-x.x.x-OS version number-64bit-Jdbc.tar.gz.
The driver package is compatible with PostgreSQL. The class name and structure in the driver are the same as those in the PostgreSQL driver. All applications running on PostgreSQL can be smoothly migrated to the current system.
Driver Class
Before establishing a database connection, load the org.opengauss.Driver database driver class.
NOTE:
- openGauss is compatible with PostgreSQL in the use of JDBC. Therefore, the org.postgresql.Driver class will conflict when the JDBC driver packages for PostgreSQL and openGauss are loaded in the same JVM virtual machine at the same time.
- Compared with the PostgreSQL driver, the openGauss JDBC driver has the following enhanced features:
- The SHA256 encryption mode is supported for login.
- The third-party log framework that implements the sf4j API can be connected.
- DR failover is supported.
Environment Class
JDK 1.8 must be configured on the client. The configuration method is as follows:
- In the MS-DOS window, run java -version to check the JDK version. Ensure that the version is JDK 1.8. If JDK is not installed, download the installation package from the official website and install it.
- Configure system environment variables.
Right-click My computer and choose Properties.
In the navigation pane, choose Advanced system settings.
In the System Properties dialog box, click Environment Variables on the Advanced tab page.
In the System variables area of the Environment Variables dialog box, click New or Edit to configure system variables. For details, see Table 1.
Table 1 Description