SQLDisconnect--Disconnect from a data source

Purpose

Specification: DB2 CLI 1.1 ODBC 1.0 ISO CLI

SQLDisconnect() closes the connection associated with the database connection handle.

After calling this function, either call SQLConnect() to connect to another database, or call SQLFreeHandle().

Syntax

SQLRETURN   SQLDisconnect    (SQLHDBC           ConnectionHandle;) /* hdbc */

Function arguments

Table 40. SQLDisconnect arguments

Data type Argument Use Description
SQLHDBC ConnectionHandle input Connection handle.

Usage

If an application calls SQLDisconnect() before it frees all the statement handles associated with the connection, DB2 CLI frees them after it successfully disconnects from the database.

If SQL_SUCCESS_WITH_INFO is returned, it means that the disconnect from the database is successful, but additional error or implementation-specific information is available. For example, a problem is encountered during processing subsequent to disconnecting the connection, or if there is no current connection because of an event that occurred independently of the application (such as communication failure).

After a successful SQLDisconnect() call, the application can reuse ConnectionHandle to make another SQLConnect() or SQLDriverConnect() request.

Return codes

Diagnostics

Table 41. SQLDisconnect SQLSTATEs

SQLSTATE Description Explanation
01002 Disconnect error. An error occurred during the disconnection. However, the disconnection succeeded. (Function returns SQL_SUCCESS_WITH_INFO.)
08003 Connection is closed. The connection specified in the argument ConnectionHandle is not open.
58004 Unexpected system failure. Unrecoverable system error.
HY001 Memory allocation failure. DB2 CLI is unable to allocate memory required to support execution or completion of the function.
HY013 Unexpected memory handling error. DB2 CLI is unable to access memory required to support execution or completion of the function.

Restrictions

None.

Related reference