티스토리 툴바

admin write
blogblogblogbloglocation loglocation logtag listtag listguest bookguest book
rss feed
Mini Ming!!

테스트 환경은
     Java SE 5.0 (JDK 1.5.0_12)
     iBATIS 2.1
로 진행했음을 미리 밝히는 바이다.

SqlMapClient 를 반환하기 위해 다음과 같은 static method 를 만들었다.

//import com.ibatis.common.resources.Resources;
//import com.ibatis.sqlmap.client.SqlMapClient;
//import com.ibatis.sqlmap.client.SqlMapClientBuilder;
//import org.apache.log4j.Logger;
//import java.io.Reader;

public static SqlMapClient getSqlMapClientInstance() {
  SqlMapClient sqlMapClient = null;

  try {
    Reader reader = Resources.getResourceAsReader("sqlmap-config.xml");
    sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader);
  } catch (Exception e) {
    e.printStackTrace();
  }

  return sqlMapClient;
}


전혀 예상치도 못한 에러가 발생했다.

ORA-12518, TNS:listener could not hand off client connection
The Connection descriptor used by the client was:


원인은 SqlMapClient...
SqlMapClient 를 하나 build 할때마다 Connection Pool 이 만들어 졌던것..
Connection Pool 자체를 여러개 만드니 (여러개라기 보다 getSqlMapClientInstance 호출할때마다 하나씩..)
Connection Pool 자체에 Maximum Connection에 걸린게 아니라
DB 자체가 Connection 허용량을 넘어섰던것.. ㅜ.ㅡ

메뉴얼에는 SqlMapClient 얻어오는 부분이 Singleton으로 되어있었다...
잘 모르고 바꾼 내 잘못이지.. OTL...

암튼 위의 getSqlMapClientInstance 코드는 다음과 같이 바뀌었다.

private static SqlMapClient sqlMapClient = null; // Static 멤버변수로 변경
public static SqlMapClient getSqlMapClientInstance() {
    try {
        if (sqlMapClient == null) { // null 일때 (최초 한번) 만 생성
            Reader reader = Resources.getResourceAsReader("sqlmap-config.xml");
            sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return sqlMapClient;
}


역시... 모르면 몸이 고생한다...

트랙백 보낼 주소 :: http://miniming.tistory.com/trackback/12 관련글 쓰기

댓글을 달아주세요:: 네티켓은 기본, 스팸은 사절

◀ PREV : [1] : [2] : [3] : [4] : [5] : ... [12] : NEXT ▶