Help Center/ GaussDB/ Developer Guide(Distributed_V2.0-8.x)/ Application Development Guide/ Development Based on JDBC/ Development Process/ Obtaining the JAR Package of the Driver and Configuring the JDK Environment
Updated on 2025-06-27 GMT+08:00

Obtaining the JAR Package of the Driver and Configuring the JDK Environment

Environment preparation includes obtaining the driver JAR package and configuring the JDK environment.

Obtaining the Driver Package

Download the driver package and its verification package listed in Table 1.

Table 1 Driver package download list

Version

Download Address

V2.0-8.x

Driver package

Verification package for the driver package

To prevent a software package from being tampered with during transmission or storage, download the corresponding verification package and perform the following steps to verify the software package:
  • Verifying the software package integrity on a Linux server:
    1. Upload the software package and verification package to the same directory on the VM.
    2. Run the following command to verify the integrity of the software package:

      cat GaussDB_driver.zip.sha256 | sha256sum --check

      If OK is displayed in the command output, the verification is successful.

      GaussDB_driver.zip: OK
  • Verifying the software package integrity on a Windows server:
    1. Press Win+R to open the Run dialog box. Type cmd in the text box and press Enter to open the Command Prompt window.
    2. Run the following command to obtain the hash value of the driver package:

      certutil -hashfile {local_directory_of_the_driver_package}\{driver_package_name} sha256

      • Replace {local_directory_of_the_driver_package} with the actual download path, for example, C:\Users.
      • Replace {driver_package_name} with the name of the downloaded driver package, for example, GaussDB_driver.zip.

      Example: certutil -hashfile C:\Users\GaussDB_driver.zip sha256

    3. Compare the hash value obtained in 2 with the hash value of the verification package obtained in Table 1.
      • If they are consistent, the verification is successful.
      • If they are inconsistent, download the driver package again and repeat 1 to 3 to verify the driver package.

Decompressing the Driver Package

Decompress the obtained driver package, find the JDBC driver package GaussDB-Kernel_Database version number_OS_64bit_Jdbc.tar.gz, and decompress it. The following JAR driver packages can be obtained:
  • gaussdbjdbc.jar: The main class name is com.huawei.gaussdb.jdbc.Driver. The URL prefix of the database connection is jdbc:gaussdb. This driver package is recommended. The Java code examples in this section use the gaussdbjdbc.jar package by default.
  • gscejdbc.jar: The main class name is com.huawei.gaussdb.jdbc.Driver. The URL prefix of the database connection is jdbc:gaussdb. This driver package contains the dependent libraries related to encryption and decryption that need to be loaded to the encrypted database. You are advised to use this driver package in encrypted scenarios. Currently, only EulerOS is supported.
  • gaussdbjdbc-JRE7.jar: The main class name is com.huawei.gaussdb.jdbc.Driver. The URL prefix of the database connection is jdbc:gaussdb. The gaussdbjdbc-JRE7.jar package is used in the JDK 1.7 environment.
  • Before using the gscejdbc.jar driver package, you need to set the environment variable LD_LIBRARY_PATH. For details, see section "Setting Encrypted Equality Queries > Using JDBC to Operate an Encrypted Database" in Feature Guide.
  • In JDK 1.8, you are advised to use gaussdbjdbc.jar instead of gaussdbjdbc-JRE7.jar.
  • The JAR packages of the JDBC release package are classified by architecture. The gscejdbc.jar package can be used only when it is consistent with the deployment environment. Other JAR packages do not need to be consistent with the deployment environment.
  • For details about other JDBC JAR packages, see JDBC Compatibility Package.

Configuring the JDK Environment

The JDK environment must be configured on the client. Currently, JDK 1.8 and JDK 1.7 are supported. This section uses JDK 1.8 as an example. JDK supports multiple platforms such as Windows and Linux. The following example describes the configuration method using Windows:

  1. Enter the following command in the MS-DOS window (command prompt in Windows) to check the JDK version.

    java -version

    Ensure that the JDK 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 System window, click Advanced system settings in the navigation pane.
    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 about the variables, see Table 2.
      Table 2 Variables

      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

      Click Edit.

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

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

      CLASSPATH

      Click New.

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