This document describes the cases where the connection is disconnected in the application program and the error codes and messages in each situation.
In the following situations, the connection is not established.
If the application program is written in ALTIBASE Embedded SQL (APRE*C/C++), the values that can be checked are as follows.
If the application is written in SQLCLI, the following values can be checked.
It can be checked by calling SQLError(env,dbc,stmt,state,err,msg,msgMax,msgLength).
In case of not connecter or previously disconnected
[APRE*C/C++] ==================================================== sqlca STRUCTURE .sqlcode [-2] (SQL_ERROR) .sqlerrm.sqlerrmc The connection does not exist. (Name:default connection) SQLCODE [-2] SQLSTATE ["08003"] ==================================================== [SQLCLI/ODBC] 1. In case of haven't connected ==================================================== return value [-2] SQLError(env,dbc,stmt,state,err,msg,msgMax,msgLength) error state (state) [""] error number (err) [0] in Hex(0) error message (msg) [ ?] ==================================================== 2. In case of disconnected before ==================================================== return value [-1] (SQL_ERROR) SQLError(env,dbc,stmt,state,err,msg,msgMax,msgLength) error state (state) ["08003"] error number (err) [331830] in Hex(51036) error message (msg) [Connection does not exist (err8)] ==================================================== |
In case of the connection is disconnected (the server disconnection or a network error)
[APRE*C/C++] ==================================================== sqlca STRUCTURE .sqlcode [-1] .sqlerrm.sqlerrmc [Communication link failure('errno')] SQLCODE [-331843] in Hex(51043) SQLSTATE ["08S01"] ==================================================== [SQLCLI/ODBC] ==================================================== return value [-1] SQLError(env,dbc,stmt,state,err,msg,msgMax,msgLength) error state (state) ["08S01"] error number (err) [331843] in Hex(51043) error message (msg) [Communication link failure('errno')] ==================================================== |
In case of the query was executed again without detecting that the connection was previously disconnected.
[APRE*C/C++] ==================================================== sqlca STRUCTURE .sqlcode [-1] .sqlerrm.sqlerrmc [Connection does not exist (err11)] SQLCODE [-1] SQLSTATE ["08003"] ==================================================== [SQLCLI/ODBC] ==================================================== return value [-1] SQLError(env,dbc,stmt,state,err,msg,msgMax,msgLength) error state (state) ["08003"] error number (err) [331830] in Hex(51036) error message (msg) [Connection does not exist (err8)] ==================================================== |
In case of disconnection by Timeout
Fetch Timeout, UTrans Timeout, Idle Timeout all return the same error. (Timeout is recorded in altibase_boot.log.)
[APRE*C/C++] ==================================================== sqlca STRUCTURE .sqlcode [-1] .sqlerrm.sqlerrmc [Communication link failure(131)] SQLCODE [-331843] in Hex(51043) SQLSTATE ["08S01"] ==================================================== [SQLCLI/ODBC] ==================================================== return value [-1] SQLError(env,dbc,stmt,state,err,msg,msgMax,msgLength) error state (state) ["08S01"] error number (err) [331843] in Hex(51043) error message (msg) [Communication link failure(131)] ==================================================== |
In case of the DB server is shutdown
[APRE*C/C++] ==================================================== sqlca STRUCTURE .sqlcode [-1] .sqlerrm.sqlerrmc [Communication link failure(131)] SQLCODE [-331843] in Hex(51043) SQLSTATE ["08S01"] ==================================================== [SQLCLI/ODBC] ==================================================== return value [-1] SQLError(env,dbc,stmt,state,err,msg,msgMax,msgLength) error state (state) ["08S01"] error number (err) [331843] in Hex(51043) error message (msg) [Communication link failure(131)] ==================================================== |
Connection failure
[APRE*C/C++] ==================================================== sqlca STRUCTURE .sqlcode [-1] .sqlerrm.sqlerrmc [Client unable to establish connection] SQLCODE [-327730] [50032] SQLSTATE [08001] ==================================================== [SQLCLI/ODBC] ==================================================== return value [-1] SQLError(env,dbc,stmt,state,err,msg,msgMax,msgLength) error state (state) [08001] error number (err) [327730] in Hex(50032) error message (msg) [Client unable to establish connection] ==================================================== |
As a result of checking the error code for each situation, there are 3 cases as follows.