2013-03-06 1 views
0

포털 방문자 수 (온라인, 매일, 매주, 매월, 매년)를 표시하는 간단한 포틀릿이 있습니다.com.ibm.db2.jcc.am.SqlException : 유효하지 않은 조작 : 결과 세트가 닫힙니다. ERRORCODE = -4470, SQLSTATE = null

doView 메소드의 포틀릿 클래스에서 먼저 테이블에 삽입하는 메소드 (새 방문자에 대한 정보)를 호출합니다. 내가 같은 테이블에서 count select를하는 5 가지 방법을 하나씩 호출 한 후에. 그것들은 모두 매우 유사하며 쿼리 만 다릅니다. 방법의 한 구현은 다음과 같다 :

public static Integer getOnline() { 
    Integer res = null; 
    Statement stmt = null; 
    ResultSet rs = null; 

    try { 
     stmt = getConnection().createStatement(); 
     rs = stmt.executeQuery(query); 
     if (rs.next()) { 
      res = new Integer(rs.getString("1")); 
     } 
    } catch (SQLException e) { 
     log.error("Excepton: " + e); 
    } finally { 
     if (rs != null) { 
      try { rs.close(); } catch (SQLException e) { log.warn("Error closing result set: ", e); } 
      rs = null; 
     } 

     if (stmt != null) { 
      try { stmt.close(); } catch (SQLException e) { log.warn("Error closing statement: ", e); } 
      stmt = null; 
     } 
    } 

    return res; 
} 

연결이 얻어진다

public static Connection getConnection() { 
    try { 
     if (connection == null) { 
      if (dataSource == null) { 
       dataSource = (DataSource) new InitialContext().lookup(dataSourceName); 
      } 

      connection = dataSource.getConnection(); 
     } 
    } catch (Exception e) { 
     log.error("Error on opening a connection: ", e); 
    } 

    return connection; 
} 

연결하는 doView이 방법의 단부에서 폐쇄된다. 가끔 예외가 발생합니다 :

com.ibm.db2.jcc.am.SqlException: [jcc][t4][10120][10898][4.14.88] Invalid operation: result set is closed. ERRORCODE=-4470, SQLSTATE=null 

하나 또는 몇 가지 방법으로 선택할 수 있습니다. 또한 때때로 다음과 같은 오류가 :

com.ibm.websphere.ce.cm.ObjectClosedException: DSRA9110E: Connection is closed. 

com.ibm.websphere.ce.cm.ObjectClosedException: DSRA9110E: Statement is closed. 

난 아직 못 찾았 인터넷 검색 후/내 경우 오류의 원인과 어떻게 고칠 수 무엇인지 깨달았다. 어떤 도움을 주시면 감사하겠습니다.

답변

0

driver 레벨 또는 preparing 성명서에서 resultSetHoldability를 설정하십시오. 이것은 당신이 겪고있는 것을 고쳐야합니다.

0

동일한 오류가 발생한 이유는 db2 연결을 닫은 다음 결과 세트를 읽으려고했기 때문입니다. 결과 세트를 읽는 동안 db2가 연결되어 있어야한다는 사실에 약간의 강조점을 두십시오.