Updated on 2025-09-04 GMT+08:00

Preparations

  • ODBC version: V500R002C10 or later.
  • Database environment: GaussDB V500R002C10 or later.
  • ODBC driver environment:

    Refer to "Application Development Guide > Development Based on ODBC > Development Procedure > Obtaining the Source Code Package, ODBC Packages, and Dependency Libraries" in Developer Guide.

  • ODBC data source:

    Refer to "Configuring a Data Source in the Linux OS" or "Configuring a Data Source in the Windows OS" under "Application Development Guide > Development Based on ODBC > Development Procedure > Connecting to a Database" in Developer Guide.

    Taking Linux environments as an example, you are advised to set parameters in the odbc.ini file as follows:

    [gaussdb]
    Driver=GaussMPP
    Servername=127.0.0.1 # IP address of the database server.
    Database=db1 # Database name.
    Username=omm # Name of a database user.
    Password=****** # Password for the database user.
    Port=8000 # Database listening port.
    Sslmode=allow # Specifies whether to enable SSL encryption. When set to allow, it means that the database server can use SSL encryption as required, but the server's authenticity is not verified.
    UseServerSidePrepare=1 # This parameter is enabled by default. If it is set to 1, the client sends PU/PBE packets in soft parsing mode. If it is set to 0, the client sends Q packets in hard parsing mode.
    UseBatchProtocol=1 # Specifies whether to enable batch query. This parameter is enabled by default.
    MaxCacheQueries=1024 # Number of prepared statements cached for each connection.
    MaxCacheSizeMiB=5 # Total size of prepared statements cached for each connection. This parameter takes effect when MaxCacheQueries is greater than 0.
    ConnSettings=set client_encoding=UTF8 # Client-side encoding, which must be consistent with server-side encoding.
    SocketTimeout=5 # Timeout interval for socket reads/writes after a connection is successfully established between the client and the server.
    TargetServerType=primary # Type of the target server to connect to. A connection can be successfully established only when the actual server type matches the value of this parameter. primary indicates that only the primary node in a primary/standby system can be connected to.
    • The MaxCacheQueries and MaxCacheSizeMiB parameters are supported in GaussDB 503.1 and later versions.
    • The SocketTimeout parameter is supported in GaussDB 505.2 and later versions.
    • The TargetServerType options of cluster-primary, cluster-standby, and cluster-mainnode are available only from GaussDB 506.0. Other options have been supported since GaussDB 505.2.

    Figure 1 shows the recommended configurations for the data source manager in Windows environments.

    Figure 1 Data source manager configurations in Windows environments

    Adjust the preceding data source configurations, including but not limited to the database server IP address, port number, and other connection parameters, to match the actual services.