1 21 22 package org.dbunit.database.statement; 23 24 import java.sql.Connection ; 25 import java.sql.SQLException ; 26 import java.util.ArrayList ; 27 import java.util.List ; 28 29 34 public class SimpleStatement extends AbstractBatchStatement 35 { 36 private final List _list = new ArrayList (); 37 38 SimpleStatement(Connection connection) throws SQLException 39 { 40 super(connection); 41 } 42 43 public void addBatch(String sql) throws SQLException 44 { 45 _list.add(sql); 46 } 47 48 public int executeBatch() throws SQLException 49 { 50 int result = 0; 51 for (int i = 0; i < _list.size(); i++) 52 { 53 String sql = (String )_list.get(i); 54 boolean r = _statement.execute(sql); 55 if(!r) 56 { 57 result += _statement.getUpdateCount(); 58 } 59 } 60 return result; 61 } 62 63 public void clearBatch() throws SQLException 64 { 65 _list.clear(); 66 } 67 } 68 69 70 71 72 73 | Popular Tags |