I am having trouble running some dbunit tests against Postgres.
I’ve managed to extract some data from the database into an XML file with no trouble at all, using the following code:
IDatabaseConnection connection = new DatabaseConnection( conn );
QueryDataSet partialDataSet = new QueryDataSet(connection);
partialDataSet.addTable("mytable", " SELECT * FROM mytable WHERE id=1068 ");
FlatXmlWriter datasetWriter = new FlatXmlWriter(new FileOutputStream("mydata.xml"));
datasetWriter.write( partialDataSet );
But then I can’t reload it using the following code:
DatabaseOperation.INSERT.execute(connection, new FlatXmlDataSet( this.getClass().getClassLoader().getResourceAsStream( "mydata.xml")));
The error I get is a variation on org.dbunit.dataset.NoSuchTableException: mytable.
I’ve tried specifiing the schema when I create the connection, I’ve tried editing the xml to include the schema. I thought it was a problem with case, as sometimes the error message shows the table name in uppercase depending on what I have fiddled with, but it seems to make no difference. The table is definitely there as I extracted data from it fine. Argh what a nuisance.
