spring 과 ibatis에서 insert구분을 여러개 돌릴 경우 batch를 이용하는데 있다
ORA-01000: 최대 열기 커서 수를 초과 에러가 떠서 보니 insert 구문이 300개가 넘어버려서
에러나 나네요
그래서 구글신에게 물어본 결과 아래와 같이 하면 잘 돌아갑니다.
참조
public void insertEmpSalmst(final List<SalAllSalaryModel> salpaylist) throws DataAccessException {
super.execute(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
try {
int count = 0, total = 0;
executor.startBatch();
for (SalAllSalaryModel model : salpaylist) {
executor.insert("ibatis 쿼리", model);
}
count++;
if (count % DB_BATCH_SIZE== 0) {
total += executor.executeBatch();
executor.startBatch();
}
}
total += executor.executeBatch();
} catch (RuntimeException e) {
e.printStackTrace();
}
return null;
}
});
}
'프로그램 > spring' 카테고리의 다른 글
Spring3 초간단 파일업로드 (0) | 2012.04.18 |
---|---|
답글형계시판 일단 소스 압축해서 먼저 올립니다. (0) | 2012.03.28 |