Overview
This document describes the cases where the connection is disconnected in the application program and the error codes and messages in each situation.
Version
- This document is written based on ALTIBASE HDB version 6.3.1.
- For additional information or updates, please leave a request at http://support.altibase.com/en/ or leave a comment on this page.
When the connection is disconnected from the application program
In the following situations, the connection is not established.
- It is not connected
- Communication socket error or disconnection from the server-side
- If a previously disconnected connection was not detected (if the connection was previously disconnected)
- If it is disconnected by timeout
There are Query Timeout, Fetch Timeout, UTrans Timeout, and Idle Timeout. In the case of Query Timeout, the connection is not disconnected, but in all other cases, the connection is disconnected. - When the DB Server is shutdown
- If the connection is not possible because the DB server is shutdown (Connect failure)
How to check error codes and error messages for each application program
If the application program is written in ALTIBASE Embedded SQL (APRE*C/C++), the values that can be checked are as follows.
- sqlca.sqlcode (query execution return value - SQL_SUCCESS, SQL_ERROR, etc)
- sqlca.sqlerrm.sqlerrmc (error message)
- SQLCODE (error code)
- SQLSTATE (state code)
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).
- state (state code)
- err (error code)
- msg (error message)
Connection error state and error message
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] ====================================================
Conclusion
As a result of checking the error code for each situation, there are 3 cases as follows.
- - SQLSTATE(state) ["08001"] SQLCODE [1(0x01)] errno [32770(0x050032)]
Connection failure - - SQLSTATE(state) ["08003"] SQLCODE(errno) [331830(0x051036)]
In case of not connected (after disconnection)
In case the connection is already disconnected - - SQLSTATE(state) ["08S01"] SQLCODE(errno) [331843(0x051043)]
Socket disconnection
In case of interruption due to timeout
In case of the server being shutdown