Hitachi

Hitachi Advanced Database Application Development Guide


15.4 Connecting to an HADB server by using the HADB ODBC driver

To connect to the HADB server by using the HADB ODBC driver, use the following two ODBC functions.

  1. ODBC functions to assign handles

    • SQLAllocHandle

  2. ODBC functions to establish a connection between the HADB ODBC driver and the data source (HADB server)

    Execute one of the following ODBC functions:

    • SQLConnect or SQLConnectW

    • SQLDriverConnect or SQLDriverConnectW

    • SQLBrowseConnect or SQLBrowseConnectW

The following describes important points when using the aforementioned ODBC functions.

SQLAllocHandle

First, assign an environment handle. After that, use the allocated environment handle to allocate a connection handle. The allocated connection handle is used to establish a connection between the HADB ODBC driver and the data source (the HADB server) by executing functions such as SQLConnect.

For details on SQLAllocHandle, refer to 16.3.1 SQLAllocHandle.

SQLConnect or SQLConnectW

Specify, as function arguments, the data source name, authorization identifier, and password required to establish the connection. All arguments must be specified.

For details on SQLConnect or SQLConnectW, refer to 16.3.2 SQLConnect, SQLConnectW.

SQLDriverConnect or SQLDriverConnectW, and SQLBrowseConnect or SQLBrowseConnectW

When connecting, the following must be specified in the connection string:

  • Connection string with data source name (DSN) or ODBC driver name (DRIVER)

  • Authorization identifier (UID)

  • Password (PWD)

The following shows examples of connection character string specifications:

  • For connections that specify a data source name

    "DSN=XXXXX;UID=YYYYY;PWD=ZZZZZ"

  • For connections that specify an ODBC driver name

    "DRIVER=Hitachi Advanced Database ODBC Driver;UID=YYYYY;PWD=ZZZZZ"

For details on SQLDriverConnect or SQLDriverConnectW, refer to 16.3.3 SQLDriverConnect, SQLDriverConnectW. For details on SQLBrowseConnect or SQLBrowseConnectW, refer to 16.3.4 SQLBrowseConnect, SQLBrowseConnectW.