DB OpenCursor 처리 문제 0 2 1,916

by 다말이야 [SQL Query] [2014.10.15 16:58:59]


안녕하세요

지난번에도 문의드렸지만 해결 실말이가 없어 다시 재문의 드립니다.

도대체 어느 부분에서 cursor가 오픈 되는지 궁금합니다.

 현재 소스 구조상 jar file Lib 를 호출해서 사용함에 따라

초보자인 입장에서 소스분석이 어렵네요 ㅜㅜ

jar 내부클래스를 호출하였을시 어떤방식으로 close 처리하여야 하는지 도와주세요 ㅜㅜ

 

# 소스부분

PosGenericDao dao 를 Param으로 받아서 하기와 같이 쿼리 날림

rowset = dao.find("A01190101_SELLIST",whereClause,JspUtil.setWhereParameter(params));

# JarLib 부분

public Connection getDBConnection()
  {
    return getConnection();
  }

  public CallableStatement getCallableStatement(String paramString)
  {
    CallableStatement localCallableStatement = null;
    PosQueryDefinition localPosQueryDefinition = getQueryDefinition(paramString);
    String str = localPosQueryDefinition.getQueryStatement();
    try
    {
      localCallableStatement = getConnection().prepareCall(str);
      int i = localPosQueryDefinition.getFetchSize();
      if (i > 0)
      {
        localCallableStatement.setFetchSize(i);
      }
    }
    catch (Exception localException)
    {
      throw new PosException("Can not create CallableStatement!! SQL [" + str + "]", localException);
    }
    return localCallableStatement;
  }

 

 

by 비주류 [2014.10.16 11:37:56]

본문 내용만으로는 PosGenericDao와 jar class 의 getCallableStatement 연관성을 확신할 수가 없어서,
dao.find 내부에서 getCallableStatement 를 호출하는 것까지 확인하신 것으로 가정하고 씁니다.

 

1. 제가 알기로는 cursor open 시점은 Statement execute 시점입니다. (prepare 시점 아님)
resource 관리상 ResultSet fetch 등 사용 이후엔 close 해주셔야 하구요.
그런데 close statement 하더라도 cursor cache 때문에 바로 close 되진 않습니다.
(이 때문에 debugging 이 조금 어려운 부분도 있겠네요)

 

2. dao.find 내부에서 getCallableStatement -> execute -> fetch & store(rowset) -> close 할 것이라 예상 되지만 다른 소스를 더 확인하지 않는한 본문 내용만으로는 어디서 cursor가 open, close 되는지 알 수 없습니다.
가능하다면 statement.close 부분을 추가로 확인하셔야 할 것 같습니다.

 

3. 추가로 getCallableStatement 내부에서 getConnection 하는데 1회성이라 참조가 사라지기에 이걸 나중에 어떻게 close 하는지 확인해보시는게 좋겠습니다.
(자체 connection pool manager 에서 주기적으로 확인해서 끊는지 등)

 

두서 없지만 조금 실마리를 얻으셨길 바라며...


by 다말이야 [2014.10.16 16:16:41]

PosGenericDao 의 JAR 파일에서는 DB 관련 호출이

Connection, CallableStatement  2개밖에 없습니다 ㅜ

아래와 같이 close 를 해줘도 계속 open 상태이며

((Statement) dao.getCallableStatement("A01190101_SELLIST")).close();
((PreparedStatement) dao.getCallableStatement("A01190101_SELLIST")).close();
((CallableStatement) dao.getCallableStatement("A01190101_SELLIST")).close();

아래와같이 Connection을 close 를 하면 에러가 나는군요ㅜㅜㅜㅜ

((CallableStatement) dao.getDBConnection()).close();

댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입