FAQ
Connection 연결이 끊어지는 경우와 각 경우의 에러 코드 및 에러 메세지(SESC, SQLCLI)
분류 프로그래밍 등록일 2013-07-09 조회수 17468
mskim 2005-01-27 161


요약
++++
응용프로그램에서 커넥션이 단절되는 경우와 각 상황에서의 에러 코드,메시지를
확인함.


응용프로그램에서 Connection이 단절되는 경우
+++++++++++++++++++++++++++++++++++++++++++
다음과 같은 상황들을 생각해 볼 수 있다.

1. Connect를 안한 경우
2. 통신소켓이상이나 서버쪽에서 연결을 끊은 경우
3. 이전에 끊어진 연결을 감지 못했을 경우 (이전에 Connection이 단절된 경우)
4. Timeout에 의해 끊어진 경우.
- Query Timeout, Fetch Timeout, UTrans Timeout, Idle Timeout이 있으며
Query Timeout의 경우에는 Connection이 끊기지 않으나 이외에 나머지 경우는
모두 Connection이 끊어진다.
5. DB Server가 종료된 경우
6. DB Server가 종료되어 있어 연결은 못하는 경우 (Connect 실패)


각 상황 별 에러 코드와 에러 메시지
++++++++++++++++++++++++++++++++++
응용프로그램이 SES로 작성된 경우 확인할 수 있는 값은 다음과 같다.
- sqlca.sqlcode (쿼리 수행 리턴값 - SQL_SUCCESS, SQL_ERROR, etc)
- sqlca.sqlerrm.sqlerrmc (에러메시지)
- SQLCODE (에러코드)
- SQLSTATE (상태코드)

응용프로그램이 SQLCLI로 작성된 경우 확인할 수 있는 값은 다음과 같다.
SQLError(env,dbc,stmt,state,err,msg,msgMax,msgLength) 를 호출하여
- state (상태코드)
- err (에러코드)
- msg (에러메시지)

1. Connect를 안했거나 이전에 Disconnect 한 경우

[SESC]
====================================================
sqlca STRUCTURE
.sqlcode [-1] (SQL_ERROR)
.sqlerrm.sqlerrmc [Connection does not exist]
SQLCODE [-1] [1]
SQLSTATE ["08003"]
====================================================

[SQLCLI]
이전에 한번도 connect를 안한 경우
====================================================
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) [ ?]
====================================================
이전에 disconnect 한 경우
====================================================
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)]
====================================================

2. Connection이 단절된 경우 (서버에서 끊었거나 네트워크 에러)

[SESC]
====================================================
sqlca STRUCTURE
.sqlcode [-1]
.sqlerrm.sqlerrmc [Communication link failure('errno')]
SQLCODE [-331843] in Hex(51043)
SQLSTATE ["08S01"]
====================================================

[SQLCLI]
====================================================
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')]
====================================================

3. 이전에 연결이 단절된 것을 감지 못하고 다시 쿼리를 수행한 경우

[SESC]
====================================================
sqlca STRUCTURE
.sqlcode [-1]
.sqlerrm.sqlerrmc [Connection does not exist (err11)]
SQLCODE [-1]
SQLSTATE ["08003"]
====================================================

[SQLCLI]
====================================================
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)]
====================================================

4. Timeout에 의해 단절된 경우

Fetch Timeout, UTrans Timeout, Idle Timeout 모두 같은 에러가 리턴됨.
(altibase_boot.log에 timeout 내용이 기록됨.)

[SESC]
====================================================
sqlca STRUCTURE
.sqlcode [-1]
.sqlerrm.sqlerrmc [Communication link failure(131)]
SQLCODE [-331843] in Hex(51043)
SQLSTATE ["08S01"]
====================================================

[SQLCLI]
====================================================
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)]
====================================================

5. DB Server가 종료된 경우

[SESC]
====================================================
sqlca STRUCTURE
.sqlcode [-1]
.sqlerrm.sqlerrmc [Communication link failure(131)]
SQLCODE [-331843] in Hex(51043)
SQLSTATE ["08S01"]
====================================================

[SQLCLI]
====================================================
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)]
====================================================

6. Connect 실패
[SESC]
====================================================
sqlca STRUCTURE
.sqlcode [-1]
.sqlerrm.sqlerrmc [Client unable to establish connection]
SQLCODE [-327730] [50032]
SQLSTATE [08001]
====================================================

[SQLCLI]
====================================================
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]
====================================================


결론
++++

각 상황별로 에러코드로 확인한 결과 다음과 같이 3가지의 경우가 있다.

- SQLSTATE(state) ["08001"] SQLCODE [1(0x01)] errno [32770(0x050032)]
* connect 실패

- SQLSTATE(state) ["08003"] SQLCODE(errno) [331830(0x051036)]
* Connect를 안하고 (disconnect 한 후) 수행하는 경우
* 이미 Connect가 끊어져 있는 경우

- SQLSTATE(state) ["08S01"] SQLCODE(errno) [331843(0x051043)]
* socket 단절
* timeout에 의해 끊어진 경우
* 서버가 종료되있는 경우

목록