jdbcTemplateを使用したバッチ手動コミットトランザクション



Batch Manual Commit Transaction Using Jdbctemplate



DAO`
protected int [] batchExcute(final String sql、final List args){

int[] temp=jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { Object[] os = args.get(i) for (int n = 0 n

}



//最初に自動的に閉じるように設定
jdbcTemplate.getDataSource()。getConnection()。setAutoCommit(false)

//バッチコード
//..。



jdbcTemplate.getDataSource()。getConnection()。commit()//手動で送信
jdbcTemplate.getDataSource()。getConnection()。setAutoCommit(true)//復元


上記の処理エラーが発生した場合は、getConnection()をconn変数に割り当て、その後conn操作を使用することを検討できます。