SQLDisconnect() closes the connection associated with the database connection handle.
After calling this function, either call SQLConnect() to connect to another database, or call SQLFreeConnect().
SQLRETURN SQLDisconnect (SQLHDBC hdbc);
Data type | Argument | Use | Description |
---|---|---|---|
SQLHDBC | hdbc | Input | Connection handle |
If an application calls SQLDisconnect before it has freed all the statement handles associated with the connection, DB2® UDB CLI frees them after it successfully disconnects from the database.
After a successful SQLDisconnect() call, the application can re-use hdbc to make another SQLConnect() request.
If the hdbc is participating in a DUOW two-phase commit connection, the disconnect might not occur immediately. The actual disconnect occurs at the next commit issued for the distributed transaction.
SQLSTATE | Description | Explanation |
---|---|---|
01002 | Disconnect error | An error occurred during the disconnect. However, the disconnect succeeded. (Function returns SQL_SUCCESS_WITH_INFO.) |
08003 | Connection not open | The connection specified in the argument hdbc is not open. |
25000 | Transaction state that is not valid | There is a transaction in process on the connection specified by the argument hdbc. The transaction remains active, and the connection cannot be disconnected. |
58004 | System error | Unrecoverable system error. |
HY001 | Memory allocation failure | The driver is unable to allocate memory required to support the processing or completion of the function. |
HY013 * | Memory management problem | The driver is unable to access memory required to support the processing or completion of the function. |
Refer to the example in SQLAllocEnv - Allocate environment handle.