Create test for full dataset export. I'm using Oracle 11g database and after test run i see this:
org.dbunit.DatabaseUnitRuntimeException: At least one column is required to build a valid select statement. Cannot load data for table=APEX_040000.SYS_IOT_OVER_16977, cols=[], pk=[]
In database this table is empty and I can't drop it. How can I export all dataset from db?
These are the different types of exports:
public class DatabaseExportSample{
public static void main(String[] args) throws Exception{
// database connection
Class driverClass = Class.forName("org.hsqldb.jdbcDriver");
Connection jdbcConnection = DriverManager.getConnection(
"jdbc:hsqldb:sample", "sa", "");
IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
// partial database export
QueryDataSet partialDataSet = new QueryDataSet(connection);
partialDataSet.addTable("FOO", "SELECT * FROM TABLE WHERE COL='VALUE'");
partialDataSet.addTable("BAR");
FlatXmlDataSet.write(partialDataSet, new FileOutputStream("partial.xml"));
// full database export
IDataSet fullDataSet = connection.createDataSet();
FlatXmlDataSet.write(fullDataSet, new FileOutputStream("full.xml"));
// dependent tables database export: export table X and all tables that
// have a PK which is a FK on X, in the right order for insertion
String[] depTableNames =
TablesDependencyHelper.getAllDependentTables( connection, "X" );
IDataSet depDataset = connection.createDataSet( depTableNames );
FlatXmlDataSet.write(depDataSet, new FileOutputStream("dependents.xml"));
}
}
Visit: http://dbunit.sourceforge.net/faq.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With