database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
ㆍDB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
DB2 Q&A 1549 게시물 읽기
No. 1549
SQLGetConnectAttr()
작성자
낭만자객
작성일
2008-03-06 16:52
조회수
9,600

DB2 CLI에서 현재 DB 연결 상태를 확인하기 위해 SQLGetConnectAttr() 함수를 사용하지요.


Connection Attribute SQL_ATTR_CONNECTION_DEAD의 리턴 값이 


SQL_CD_FALSE 이면 Connection still active, SQL_CD_TRUE 이면 Connection Terminated 로 판단합니다.


그런데,, 이 방법 외에 현재 DB 연결 상태 여부를 확인할 수 있는 다른 방법이 있을런지요?






이 글에 대한 댓글이 총 3건 있습니다.

While an application can set statement attributes using SQLSetConnectAttr(),
an application cannot use SQLGetConnectAttr() to retrieve statement attribute values;
it must call SQLGetStmtAttr() to retrieve the setting of statement attributes. 


http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp

사용 방법은 위에서 SQLSetConnectAttr 로 검색을 해보세요

 

벽타는 냥이님이 2008-03-06 17:41에 작성한 댓글입니다. Edit

답변 감사합니다.


그런데, 답변해주신 내용으로 봐서는 statement attribute를 setting 하기 위해 SQLSetConnectAttr()을 사용할때는 SQLGetConnectAttr()을 사용할 수 없다라는 건데...


SQLSetConnectAttr()을 쓰긴 씁니다만, statement attribute를 위해서가 아니라 connection attribute인 SQL_ATTR_AUTOCOMMIT을 사용하기 위해서 입니다.


이런 경우에도 SQLGetConnectAttr()을 SQLSetConnectAttr()과 함께 쓸 수 없는건가요?


낭만자객님이 2008-03-06 18:02에 작성한 댓글입니다.
이 댓글은 2008-03-06 18:05에 마지막으로 수정되었습니다. Edit

  printf("1. ########################## AUTOCOMMIT_OFF ##########################\n");

  /* set AUTOCOMMIT off */
  cliRC = SQLSetConnectAttr(hdbc,
                            SQL_ATTR_AUTOCOMMIT,
                            (SQLPOINTER)SQL_AUTOCOMMIT_OFF,
                            SQL_NTS);
  DBC_HANDLE_CHECK(hdbc, cliRC);
 
  /* get the current setting for the AUTOCOMMIT attribute */
  cliRC = SQLGetConnectAttr(hdbc, SQL_AUTOCOMMIT, &autocommit, 0, NULL);
  DBC_HANDLE_CHECK(hdbc, cliRC);

  printf("\n  A connection attribute...\n");
  printf("    Autocommit is: ");
  printf(autocommit == SQL_AUTOCOMMIT_ON ? "ON\n" : "OFF\n");


  printf("2. ########################## AUTOCOMMIT_ON ##########################\n");

  /* set AUTOCOMMIT off */
  cliRC = SQLSetConnectAttr(hdbc,
                            SQL_ATTR_AUTOCOMMIT,
                            (SQLPOINTER)SQL_AUTOCOMMIT_ON,
                            SQL_NTS);
  DBC_HANDLE_CHECK(hdbc, cliRC);

  /* get the current setting for the AUTOCOMMIT attribute */
  cliRC = SQLGetConnectAttr(hdbc, SQL_AUTOCOMMIT, &autocommit, 0, NULL);
  DBC_HANDLE_CHECK(hdbc, cliRC);

  printf("\n  A connection attribute...\n");
  printf("    Autocommit is: ");
  printf(autocommit == SQL_AUTOCOMMIT_ON ? "ON\n" : "OFF\n");


====================>

1. ########################## AUTOCOMMIT_OFF ##########################

  A connection attribute...
    Autocommit is: OFF
2. ########################## AUTOCOMMIT_ON ##########################

  A connection attribute...
    Autocommit is: ON

벽타는 냥이님이 2008-03-06 19:48에 작성한 댓글입니다. Edit
[Top]
No.
제목
작성자
작성일
조회
1552blob입력서 에러 [1]
이남식
2008-03-10
9073
1551blob형식의 파일을 jsp에서 다운받는법좀..... [1]
이남식
2008-03-10
9769
1550Get Connection State [2]
낭만자객
2008-03-07
8667
1549SQLGetConnectAttr() [3]
낭만자객
2008-03-06
9600
1548[질문]페이징 도움 요청합니다. [1]
박준
2008-03-06
9585
1547DB2가 트랙잰션용 DB인가요? 아님 DW전용DB인가요..? [1]
배상현
2008-03-05
9257
1545cli를 이용한 테이블 생성 및 insert 질문입니다. [3]
이도희
2008-03-04
10988
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2023 DSN, All rights reserved.
작업시간: 0.052초, 이곳 서비스는
	PostgreSQL v16.1로 자료를 관리합니다