1 21 22 package org.dbunit.operation; 23 24 import org.dbunit.DatabaseUnitException; 25 import org.dbunit.database.DatabaseConfig; 26 import org.dbunit.database.IDatabaseConnection; 27 import org.dbunit.dataset.IDataSet; 28 29 import java.sql.SQLException ; 30 31 47 public class TruncateTableOperation extends DeleteAllOperation 48 { 49 TruncateTableOperation() 50 { 51 } 52 53 56 protected String getDeleteAllCommand() 57 { 58 return "truncate table "; 59 } 60 61 64 public void execute(IDatabaseConnection connection, IDataSet dataSet) 65 throws DatabaseUnitException, SQLException 66 { 67 DatabaseConfig config = connection.getConfig(); 69 boolean oldValue = config.getFeature(DatabaseConfig.FEATURE_BATCHED_STATEMENTS); 70 try 71 { 72 config.setFeature(DatabaseConfig.FEATURE_BATCHED_STATEMENTS, false); 73 super.execute(connection, dataSet); 74 } 75 finally 76 { 77 config.setFeature(DatabaseConfig.FEATURE_BATCHED_STATEMENTS, oldValue); 78 } 79 } 80 } 81 82 83 84 85 86 87 88 | Popular Tags |