Hitachi

Hitachi Advanced Database Application Development Guide


16.3.2 SQLConnect, SQLConnectW

Organization of this subsection

(1) Function

This ODBC function establishes a connection between the HADB ODBC driver and the data source (HADB server).

Note that you must have the CONNECT privilege to execute SQLConnect and SQLConnectW.

(2) Format

(3) Arguments

ConnectionHandle

Specifies the connection handle.

ServerName

Specifies the name of the data source.

NameLength1

Specifies the length# of the data source name.

If the data source name ends with the null terminating character, specify SQL_NTS.

If zero or a negative value is specified, an error results.

UserName

Specifies the user ID (authorization identifier) for connecting to the HADB server.

NameLength2

Specifies the length# of the user ID.

If the user ID ends with the null terminating character, specify SQL_NTS.

If zero or a negative value is specified, an error results.

Authentication

Specifies the password for the authorization identifier being used to connect to the HADB server. If NULL is specified, an error results.

Because of ODBC implementation conventions, we recommend that you do not use any of the following 13 characters in passwords: [, ], {, }, (, ), ,, ;, ?, *, =, !, and @. For details about the passwords supported by HADB, see Password specification rules in the HADB Setup and Operation Guide.

NameLength3

Specifies the length# of the password.

If the password ends with the null terminating character, specify SQL_NTS.

If a negative value or a value 256 or greater is specified, an error results.

Note also that if a character string whose length is 256 characters or more is specified in Authentication and SQL_NTS is specified in this argument, an error results.

#

The length must be in bytes for SQLConnect and in characters for SQLConnectW.

(4) Return value

This ODBC function returns SQL_SUCCESS, SQL_ERROR, or SQL_INVALID_HANDLE.

(5) SQLSTATE

This ODBC function returns one of the following SQLSTATE values:

SQLSTATE

Description

Remarks

Returned

01000

General warning

--

N

01S02

Option value changed

N

08001

Client unable to establish a connection

N

08002

Connection name in use

Y

08004

Server rejected the connection

N

08S01

Communication link failure

N

28000

Invalid authorization specification

Y

5C002

Character encoding conversion error

A character encoding that cannot be converted was detected.

Y

5C052

Version mismatch error

The versions of the ODBC driver and HADB client are different.

Y

5D001

HADB-specific error

An error occurred on HADB, but a specific SQLSTATE or error message cannot be obtained.

Y

HY000

General error

--

N

HY001

Memory allocation error

N

HY010

Function sequence error

Y

HY013

Memory management error

N

HY090

Invalid string or buffer length

Y

HYT00

Timeout expired

N

HYT01

Connection timeout expired

N

IM001

Driver does not support this function

N

IM002

No data source is found

and

Default driver is not specified

N

IM003

Specified driver could not be loaded

N

IM004

Driver's SQLAllocHandle on SQL_HANDLE_ENV failed

N

IM005

Driver's SQLAllocHandle on SQL_HANDLE_DBC failed

N

IM006

Driver's SQLSetConnectAttr or Driver's SQLSetConnectAttrW failed

N

IM009

Unable to load translation DLL

N

IM010

Data source name too long

N

Legend:

Y: This SQLSTATE might be returned by the HADB ODBC driver.

N: This SQLSTATE is not returned by the HADB ODBC driver.

--: None