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:

  1. 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.
  2. Compared with the PostgreSQL driver, the openGauss JDBC driver has the following enhanced features:
  3. The SHA256 encryption mode is supported for login.
  4. The third-party log framework that implements the sf4j API can be connected.
  5. DR failover is supported.

Environment Class

JDK 1.8 must be configured on the client. The configuration method is as follows:

  1. 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.
  2. Configure system environment variables.
    1. Right-click My computer and choose Properties.

    2. In the navigation pane, choose Advanced system settings.

    3. In the System Properties dialog box, click Environment Variables on the Advanced tab page.

    4. 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

      Variable

      Operation

      Variable Value

      JAVA_HOME

      • If the variable exists, click Edit.
      • If the variable does not exist, click New.

      Specifies the Java installation directory.

      Example: C:\Program Files\Java\jdk1.8.0_131

      Path

      Edit

      • If JAVA_HOME is configured, add %JAVA_HOME%\bin before the variable value.
      • If JAVA_HOME is not configured, add the full Java installation path before the variable value:

        C:\Program Files\Java\jdk1.8.0_131\bin;

      CLASSPATH

      New

      .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar;

Feedback
编组 3备份
    openGauss 2024-12-26 01:07:08
    cancel