Updated on 2023-10-23 GMT+08:00

Configuring a Data Source in the Windows OS

Configure an ODBC data source using the ODBC data source manager preinstalled in the Windows OS.

Procedure

  1. Replace the GaussDB client driver.

    Decompress GaussDB-Kernel-VxxxRxxxCxx-Windows-Odbc.tar.gz and install psqlodbc.exe (for the 32-bit OS) as required.

  2. Open Driver Manager.

    Use the ODBC Driver Manager for the 32-bit OS to configure the data source. (Currently, only the ODBC Driver Manager for the 32-bit OS is supported. The following description assumes that the OS is installed on drive C. If the OS is installed on another drive, change the path accordingly.)

    • For a 64-bit OS, open C:\Windows\SysWOW64\odbcad32.exe. Do not choose Control Panel > Administrative Tools > Data Sources (ODBC).

      WoW64 is short for Windows 32-bit on Windows 64-bit. C:\Windows\SysWOW64\ stores the 32-bit environment on a 64-bit system. C:\Windows\System32\ stores the environment consistent with the current OS. For technical details, see Windows technical documents.

    • For a 32-bit OS, open C:\Windows\System32\odbcad32.exe or choose Computer > Control Panel > Administrative Tools > Data Sources (ODBC) to open Driver Manager.

  3. Configure a data source.

    On the User DSN tab, click Add and choose PostgreSQL Unicode for setup.

    The entered username and password will be recorded in the Windows registry and you do not need to enter them again when connecting to the database next time. For security purposes, you are advised to delete sensitive information before clicking Save and enter the required username and password again when using ODBC APIs to connect to the database.

  4. Enable the SSL mode.

    Copy the client.crt, client.key, client.key.cipher, and client.key.rand files in the certificate file folder to the manually created directory %APPDATA%\postgresql. Change client in the file names to postgres, for example, change client.key to postgres.key. Copy the cacert.pem file to the %APPDATA%\postgresql directory and change its name to root.crt.

    %APPDATA% is located in C:\Users\[username]\AppData by default, and its values is specified by customers during installation.

    Change the value of SSL Mode in Step 2 to require.

    Table 1 sslmode options and description

    sslmode

    Whether SSL Encryption Is Enabled

    Description

    disable

    No

    SSL connection is not enabled.

    allow

    Possible

    If the database server requires SSL connection, SSL connection can be enabled. However, authenticity of the database server will not be verified.

    prefer

    Possible

    If the database supports SSL connection, SSL connection is preferred. However, authenticity of the database server will not be verified.

    require

    Yes

    SSL connection is required and data is encrypted. However, authenticity of the database server will not be verified.

    verify-ca

    Yes

    SSL connection is required and whether the database has a trusted certificate will be verified. Currently, Windows ODBC does not support the cert authentication.

    verify-full

    Yes

    SSL connection is required. In addition to the check scope specified by verify-ca, the system checks whether the name of the host where the database resides is the same as that in the certificate. Currently, Windows ODBC does not support the cert authentication.

Verifying the Data Source Configuration

Click Test.

  • If the following information is displayed, the configuration is correct and the connection succeeds.

  • If error information is displayed, the configuration is incorrect. Check the configuration.

FAQs

  • connect to server failed: no such file or directory

    Possible causes:

    • An incorrect or unreachable database IP address or port was configured.

      Check the Servername and Port configuration items in data sources.

    • Server monitoring is improper.

      If Servername and Port are correctly configured, ensure the proper network adapter and port are monitored by following the database server configurations in the procedure in this section.

    • Firewall and network gatekeeper settings are improper.

      Check firewall settings, and ensure that the database communication port is trusted.

      Check to ensure network gatekeeper settings are proper (if any).

  • The password-stored method is not supported.

    Possible causes:

    sslmode is not configured for the data source. Set this configuration item to allow or a higher level to enable SSL connections. For details on sslmode, see Table 1.

  • authentication method 10 not supported.

    If this error occurs on an open-source client, the cause may be:

    The database stores only the SHA-256 hash of the password, but the open-source client supports only MD5 hashes.

    • The database stores the hashes of user passwords instead of actual passwords.
    • If a password is updated or a user is created, both types of hashes will be stored, compatible with open-source authentication protocols.
    • An MD5 hash can only be generated using the original password, but the password cannot be obtained by reversing its SHA-256 hash. Passwords in the old version will only have SHA-256 hashes and not support MD5 authentication.
    • The MD5 encryption algorithm has lower security and poses security risks. Therefore, you are advised to use a more secure encryption algorithm.

    To solve this problem, you can update the user password (see ALTER USER) or create a user (see CREATE USER) having the same permissions as the faulty user.

  • unsupported frontend protocol 3.51: server supports 1.0 to 3.0

    The database version is too early or the database is an open-source database. Use the driver of the required version to connect to the database.