1 21 22 package org.dbunit.database.statement; 23 24 import org.dbunit.database.IDatabaseConnection; 25 26 import java.sql.SQLException ; 27 28 33 public class PreparedStatementFactory extends AbstractStatementFactory 34 { 35 public IBatchStatement createBatchStatement(IDatabaseConnection connection) 36 throws SQLException 37 { 38 if (supportBatchStatement(connection)) 39 { 40 return new BatchStatement(connection.getConnection()); 41 } 42 else 43 { 44 return new SimpleStatement(connection.getConnection()); 45 } 46 } 47 48 public IPreparedBatchStatement createPreparedBatchStatement(String sql, 49 IDatabaseConnection connection) throws SQLException 50 { 51 IPreparedBatchStatement statement = null; 52 if (supportBatchStatement(connection)) 53 { 54 statement = new PreparedBatchStatement(sql, connection.getConnection()); 55 } 56 else 57 { 58 statement = new SimplePreparedStatement(sql, connection.getConnection()); 59 } 60 return new AutomaticPreparedBatchStatement(statement, 1000); 61 } 62 } 63 64 65 66 67 | Popular Tags |