티스토리 뷰
http://mdbitz.com/2010/10/19/performing-batch-processing-with-ibatis-and-spring/
위 사이트 코드 참고하여 익명 이너 클래스 대신 Helper 클래스 작성하여 사용하였다.
public class UpdateBatchHelper<E> implements SqlMapClientCallback {
private Iterator<E> iterator;
private String statement;
@SuppressWarnings("unused")
private UpdateBatchHelper() {
// default 생성자는 사용하지 않는다.
}
public UpdateBatchHelper(Iterator<E> iterator, String statement) {
this.iterator = iterator;
this.statement = statement;
}
/**
* @param executor
* @return
* @throws SQLException
* @see org.springframework.orm.ibatis.SqlMapClientCallback#doInSqlMapClient(com.ibatis.sqlmap.client.SqlMapExecutor)
*/
@Override
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
executor.startBatch();
while (iterator.hasNext()) {
executor.update(statement, iterator.next());
}
return executor.executeBatch();
}
public void setIterator(Iterator<E> iterator) {
this.iterator = iterator;
}
public void setStatement(String statement) {
this.statement = statement;
}
}
'공부 > DBMS, SQL' 카테고리의 다른 글
[Mysql] DATETIME default value (0) | 2015.04.20 |
---|---|
[mysql] 재시작 (0) | 2014.12.28 |
[mysql] 컬럼명으로 테이블 찾기 (0) | 2014.11.26 |
[mysql] LAST_INSERT_ID() (0) | 2014.10.22 |
[Mysql] Table Character Set 변경 쿼리 (0) | 2013.12.26 |
- Total
- Today
- Yesterday
- SVN
- 알고리즘
- 게임
- db
- 배열
- SQL
- 자바
- 정보
- 프로젝트
- CSS
- 오라클
- 데이터베이스
- ERP
- HTML
- 충북대
- 안드로이드
- 정렬
- 이론
- 청주
- 자바스크립트
- 아두이노
- 클래스
- jsp
- 졸업작품
- 소켓
- 잡담
- 메모장
- 도전과제
- JQuery
- 파이썬
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |