title: dbunit not able to read data from dataset.xml
body: <p>I am trying to run a dbunit test case by loading data from an xml file (dataset.xml) and the program fails to find the table. I am new to dbunit and lack of good working examples is preventing me from running a simple program. Can anybody please guide on this?</p>
  
  <p><strong>Error Log</strong></p>
  
  <pre><code>SEVERE: Table 'states' not found in tableMap=org.dbunit.dataset.OrderedTableNameMap[_tableNames=[], _tableMap={}, _caseSensitiveTableNames=false]
  Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.64 sec &lt;&lt;&lt; FAILURE!
  testMe(com.istore.dao.DatabaseXmlTest)  Time elapsed: 0.579 sec  &lt;&lt;&lt; ERROR!
  org.dbunit.dataset.NoSuchTableException: states
      at org.dbunit.database.DatabaseDataSet.getTableMetaData(DatabaseDataSet.java:288)
      at org.dbunit.operation.DeleteAllOperation.execute(DeleteAllOperation.java:109)
      at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
      at org.dbunit.AbstractDatabaseTester.executeOperation(AbstractDatabaseTester.java:190)
      at org.dbunit.AbstractDatabaseTester.onSetup(AbstractDatabaseTester.java:103)
      at org.dbunit.DatabaseTestCase.setUp(DatabaseTestCase.java:156)
      at junit.framework.TestCase.runBare(TestCase.java:139)
      at junit.framework.TestResult$1.protect(TestResult.java:122)
      at junit.framework.TestResult.runProtected(TestResult.java:142)
      at junit.framework.TestResult.run(TestResult.java:125)
      at junit.framework.TestCase.run(TestCase.java:129)
      at junit.framework.TestSuite.runTest(TestSuite.java:252)
      at junit.framework.TestSuite.run(TestSuite.java:247)
      at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
      at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
      at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
      at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
      at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
      at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
  
  
  Results :
  
  Tests in error: 
    testMe(com.istore.dao.DatabaseXmlTest): states
  </code></pre>
  
  <p><strong>dataset.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;dataset&gt;
      &lt;states state_id="1" state_cd="NJ" name="New Jersey" tax_pct="6" active="Y"/&gt;
      &lt;states state_id="2" state_cd="PA" name="Pennsylvania" tax_pct="6" active="Y"/&gt;
  &lt;/dataset&gt;
  </code></pre>
  
  <p><strong>DatabaseXmlTest.java</strong></p>
  
  <pre><code>public class DatabaseXmlTest extends DataSourceBasedDBTestCase {
  
      public static final String url = "jdbc:hsqldb:mem:my-project-test;shutdown=true";
      public static final String driver = "org.hsqldb.jdbcDriver";
      public static final String user = "";
      public static final String pwd = "";
  
      @Override
      protected DataSource getDataSource() {
          BasicDataSource dataSource = new BasicDataSource();
          dataSource.setDriverClassName(driver);
          dataSource.setUsername(user);
          dataSource.setPassword(pwd);
          dataSource.setUrl(url);
          return dataSource;
      }
  
      @Override
      protected IDataSet getDataSet() throws Exception {
          InputStream inputStream = getClass().getResourceAsStream("/dataset.xml");
          Reader reader = new InputStreamReader(inputStream);
          FlatXmlDataSet dataset = new FlatXmlDataSet(reader);
          return dataset;
      }
  
      public void testMe() throws Exception {
          DataSource dataSource = getDataSource();
          HsqldbConnection cn = new HsqldbConnection(dataSource.getConnection(), null);
          DatabaseOperation.CLEAN_INSERT.execute(cn, getDataSet());
          //get all states
          List&lt;State&gt; states = new StateDao(dataSource).getAllStates();
          assertNotNull(states);
      }
  
  }
  </code></pre>
  
  <p><strong>StateDao.java</strong></p>
  
  <pre><code>public class StateDao {
  
      private static final Logger LOG = Logger.getLogger(StateDao.class);
  
      protected DataSource dataSource;
  
      public StateDao(DataSource dataSource) {
          this.dataSource = dataSource;
      }
  
      public List&lt;State&gt; getAllStates() throws SQLException {
          String sql = "select * from states a where a.active='Y'";
          StateQueryExecutor executor = new StateQueryExecutor(dataSource.getConnection(), sql);
          List&lt;State&gt; states = executor.getAllStates();
          LOG.debug("states = " + states);
          return states;
      }
  
  }
  </code></pre>