Note that there are some explanatory texts on larger screens.

plurals
  1. POusing dbunit to clean insert in a db from ant target
    primarykey
    data
    text
    <p>I use dbunit to test db operations in my webapp.Recently ,I used dbunits ant task org.dbunit.ant.DbUnitTask to create an xml representation of items in my database.I got this</p> <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt; &lt;dataset&gt; &lt;table name="AUTHOR"&gt; &lt;column&gt;AUTHOR_ID&lt;/column&gt; &lt;column&gt;AUTHOR_NAME&lt;/column&gt; &lt;column&gt;AUTHOR_ADDRESS&lt;/column&gt; &lt;row&gt; &lt;value&gt;0&lt;/value&gt; &lt;value&gt;j.k.rowling&lt;/value&gt; &lt;value&gt;london&lt;/value&gt; &lt;/row&gt; &lt;row&gt; &lt;value&gt;1&lt;/value&gt; &lt;value&gt;&lt;![CDATA[stephen king]]&gt;&lt;/value&gt; &lt;value&gt;&lt;![CDATA[castle rock,maine]]&gt;&lt;/value&gt; &lt;/row&gt; &lt;/table&gt; ... </code></pre> <p>I wanted to clean insert into the db ,values from this xml file.In a testcase's you do this by</p> <pre><code>public void init() throws FileNotFoundException, IOException, ClassNotFoundException, SQLException, DatabaseUnitException { connection = DbUnitUtils.createConnection(); try { DatabaseOperation.CLEAN_INSERT.execute(connection,DbUnitUtils.createDataSet("initialdata.xml")); }finally { connection.close(); } } </code></pre> <p>I wanted to do the same using an ant target.So I wrote</p> <pre><code>&lt;target name="insertdata" depends="startdb"&gt; &lt;dbunit driver="${db.driver}" url="${db.url}" userid="${db.username}" password="${db.password}"&gt; &lt;operation type="CLEAN_INSERT" src="data/dbunit/initialdata.xml"/&gt; &lt;/dbunit&gt; &lt;/target&gt; &lt;taskdef name="dbunit" classname="org.dbunit.ant.DbUnitTask" classpathref="clientclasspath" /&gt; </code></pre> <p>where the driver.username,password etc are taken from a properties file</p> <p>However,I get this error</p> <pre><code>insertdata: [dbunit] Executing operation: CLEAN_INSERT [dbunit] on file: C:\code\jee\myapp\data\dbunit\initialdata.xml [dbunit] with format: null [dbunit] 550 [main] ERROR org.dbunit.database.DatabaseDataSet - Table 'value' not found in tableMap=org.dbunit.dataset.OrderedTableNameMa p[_tableNames=[AUTHOR], _tableMap={AUTHOR=null}, _caseSensitiveTableNames=false] </code></pre> <p>Can anyone make sense of this error?The same xml file when passed to the method <code>DatabaseOperation.CLEAN_INSERT.execute(connection,DbUnitUtils.createDataSet("initialdata.xml"))</code> </p> <p>succeeds in cleanly inserting the data.</p> <p>Any help welcome</p> <p>thanks</p> <p>mark</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload