importing data: NoSuchTableException

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

importing data: NoSuchTableException

Antonio Diaz Sanchez
Hi,

I am trying to load an XML file into a HSQLDB (1.8) memory database by using DBUnit (2.4.7). I always get a "NoSuchTableException", and definitely I don't know what I am doing wrong.

Here is the code I am using (it is very simple):

Class.forName("org.hsqldb.jdbcDriver");
Connection jdbcConnection = DriverManager.getConnection("jdbc:hsqldb:mem:tests", "sa", "");
IDatabaseConnection conn = new DatabaseConnection(jdbcConnection);
conn.getConfig().setProperty(DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES, false);       conn.getConfig().setProperty(DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES, false);
FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
builder.setCaseSensitiveTableNames(false);
builder.setColumnSensing(true);
builder.setDtdMetadata(false);
IDataSet ds = builder.build(new File("/home/adiaz/db_output.xml"));
DatabaseOperation.CLEAN_INSERT.execute(conn, ds);



The XML that is being read is the following:

<?xml version='1.0' encoding='UTF-8'?> 
<dataset> 
  <roles id="0" code="ADM" name="ADMIN"/> 
  <roles id="1" code="MNT" name="MAINTENANCE"/> 
  <roles id="2" code="SUP" name="SUPPORT"/> 
</dataset>


And I always get the following message:

7386 [main] INFO org.dbunit.database.DatabaseDataSet - Table 'roles' not found in tableMap=org.dbunit.dataset.OrderedTableNameMap[_tableNames=[], _tableMap={}, _caseSensitiveTableNames=false]
Exception in thread "main" org.dbunit.dataset.NoSuchTableException: roles
        at org.dbunit.database.DatabaseDataSet.getTableMetaData(DatabaseDataSet.java:282)
        at org.dbunit.operation.DeleteAllOperation.execute(DeleteAllOperation.java:109)
        at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
        at extracttbo.Main.main(Main.java:40)


 I swear I have tried everything. Any idea?

 Regards,







     

------------------------------------------------------------------------------

_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: importing data: NoSuchTableException

Karl Jóhann Pálsson

Are you sure the table exists?  DBUnit won't create tables, it only fills them.  You need to create the tables yourself before hand, either via hibernate/jpa schema update, or manually creating them.

Cheers,
Karl P

-----Original Message-----
From: Antonio Diaz Sanchez [mailto:[hidden email]]
Sent: Tuesday, May 11, 2010 11:45 AM
To: [hidden email]
Subject: [dbunit-user] importing data: NoSuchTableException

Hi,

I am trying to load an XML file into a HSQLDB (1.8) memory database by using DBUnit (2.4.7). I always get a "NoSuchTableException", and definitely I don't know what I am doing wrong.

Here is the code I am using (it is very simple):

Class.forName("org.hsqldb.jdbcDriver");
Connection jdbcConnection = DriverManager.getConnection("jdbc:hsqldb:mem:tests", "sa", "");
IDatabaseConnection conn = new DatabaseConnection(jdbcConnection);
conn.getConfig().setProperty(DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES, false);       conn.getConfig().setProperty(DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES, false);
FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
builder.setCaseSensitiveTableNames(false);
builder.setColumnSensing(true);
builder.setDtdMetadata(false);
IDataSet ds = builder.build(new File("/home/adiaz/db_output.xml"));
DatabaseOperation.CLEAN_INSERT.execute(conn, ds);



The XML that is being read is the following:

<?xml version='1.0' encoding='UTF-8'?> 
<dataset> 
  <roles id="0" code="ADM" name="ADMIN"/> 
  <roles id="1" code="MNT" name="MAINTENANCE"/> 
  <roles id="2" code="SUP" name="SUPPORT"/> 
</dataset>


And I always get the following message:

7386 [main] INFO org.dbunit.database.DatabaseDataSet - Table 'roles' not found in tableMap=org.dbunit.dataset.OrderedTableNameMap[_tableNames=[], _tableMap={}, _caseSensitiveTableNames=false]
Exception in thread "main" org.dbunit.dataset.NoSuchTableException: roles
        at org.dbunit.database.DatabaseDataSet.getTableMetaData(DatabaseDataSet.java:282)
        at org.dbunit.operation.DeleteAllOperation.execute(DeleteAllOperation.java:109)
        at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
        at extracttbo.Main.main(Main.java:40)


 I swear I have tried everything. Any idea?

 Regards,







     

------------------------------------------------------------------------------

_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
------------------------------------------------------------------------------

_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: importing data: NoSuchTableException

Huber Christian (IT-DIWA)
In reply to this post by Antonio Diaz Sanchez
Hi,

I figure the table is not yet created, which is more an HSQL issue. When using the "mem" protocol i found that the database is always created from scratch, that means there are no tables inside. Try using the "file" protocol, create the tables beforehand (e.g. using hsqls sqltool or the free version of DBVisualizer - I use the later and it works like a charm) and everything should work fine.


-----Ursprüngliche Nachricht-----
Von: Antonio Diaz Sanchez [mailto:[hidden email]]
Gesendet: Dienstag, 11. Mai 2010 13:45
An: [hidden email]
Betreff: [dbunit-user] importing data: NoSuchTableException

Hi,

I am trying to load an XML file into a HSQLDB (1.8) memory database by using DBUnit (2.4.7). I always get a "NoSuchTableException", and definitely I don't know what I am doing wrong.

Here is the code I am using (it is very simple):

Class.forName("org.hsqldb.jdbcDriver");
Connection jdbcConnection = DriverManager.getConnection("jdbc:hsqldb:mem:tests", "sa", ""); IDatabaseConnection conn = new DatabaseConnection(jdbcConnection);
conn.getConfig().setProperty(DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES, false);       conn.getConfig().setProperty(DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES, false); FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder(); builder.setCaseSensitiveTableNames(false);
builder.setColumnSensing(true);
builder.setDtdMetadata(false);
IDataSet ds = builder.build(new File("/home/adiaz/db_output.xml"));
DatabaseOperation.CLEAN_INSERT.execute(conn, ds);



The XML that is being read is the following:

<?xml version='1.0' encoding='UTF-8'?> <dataset>
  <roles id="0" code="ADM" name="ADMIN"/>
  <roles id="1" code="MNT" name="MAINTENANCE"/>
  <roles id="2" code="SUP" name="SUPPORT"/> </dataset>


And I always get the following message:

7386 [main] INFO org.dbunit.database.DatabaseDataSet - Table 'roles' not found in tableMap=org.dbunit.dataset.OrderedTableNameMap[_tableNames=[], _tableMap={}, _caseSensitiveTableNames=false] Exception in thread "main" org.dbunit.dataset.NoSuchTableException: roles
        at org.dbunit.database.DatabaseDataSet.getTableMetaData(DatabaseDataSet.java:282)
        at org.dbunit.operation.DeleteAllOperation.execute(DeleteAllOperation.java:109)
        at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
        at extracttbo.Main.main(Main.java:40)


 I swear I have tried everything. Any idea?

 Regards,







     

------------------------------------------------------------------------------

_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user

------------------------------------------------------------------------------

_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: importing data: NoSuchTableException

Antonio Diaz Sanchez
In reply to this post by Karl Jóhann Pálsson

Thank both of you. I thought that DBUnit was reponsible for creating the
tables. In fact, I used JPA for my first DBUnit test and that confused
me, because that drived me to think that the creation was done by
DBUnit. It is a pitty that the XML does not include some kind of
metadata that could help to support to this feature.

  *Thank you*. Regards,



El 05/11/2010 12:47 PM, Karl Jóhann Pálsson escribió:

>
> Are you sure the table exists?  DBUnit won't create tables, it only fills them.  You need to create the tables yourself before hand, either via hibernate/jpa schema update, or manually creating them.
>
> Cheers,
> Karl P
>
> -----Original Message-----
> From: Antonio Diaz Sanchez [mailto:[hidden email]]
> Sent: Tuesday, May 11, 2010 11:45 AM
> To: [hidden email]
> Subject: [dbunit-user] importing data: NoSuchTableException
>
> Hi,
>
> I am trying to load an XML file into a HSQLDB (1.8) memory database by using DBUnit (2.4.7). I always get a "NoSuchTableException", and definitely I don't know what I am doing wrong.
>
> Here is the code I am using (it is very simple):
>
> Class.forName("org.hsqldb.jdbcDriver");
> Connection jdbcConnection = DriverManager.getConnection("jdbc:hsqldb:mem:tests", "sa", "");
> IDatabaseConnection conn = new DatabaseConnection(jdbcConnection);
> conn.getConfig().setProperty(DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES, false);       conn.getConfig().setProperty(DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES, false);
> FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
> builder.setCaseSensitiveTableNames(false);
> builder.setColumnSensing(true);
> builder.setDtdMetadata(false);
> IDataSet ds = builder.build(new File("/home/adiaz/db_output.xml"));
> DatabaseOperation.CLEAN_INSERT.execute(conn, ds);
>
>
>
> The XML that is being read is the following:
>
> <?xml version='1.0' encoding='UTF-8'?>
> <dataset>
>    <roles id="0" code="ADM" name="ADMIN"/>
>    <roles id="1" code="MNT" name="MAINTENANCE"/>
>    <roles id="2" code="SUP" name="SUPPORT"/>
> </dataset>
>
>
> And I always get the following message:
>
> 7386 [main] INFO org.dbunit.database.DatabaseDataSet - Table 'roles' not found in tableMap=org.dbunit.dataset.OrderedTableNameMap[_tableNames=[], _tableMap={}, _caseSensitiveTableNames=false]
> Exception in thread "main" org.dbunit.dataset.NoSuchTableException: roles
>          at org.dbunit.database.DatabaseDataSet.getTableMetaData(DatabaseDataSet.java:282)
>          at org.dbunit.operation.DeleteAllOperation.execute(DeleteAllOperation.java:109)
>          at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
>          at extracttbo.Main.main(Main.java:40)
>
>
>   I swear I have tried everything. Any idea?
>
>   Regards,
>
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
> ------------------------------------------------------------------------------
>
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user

               
______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y m�viles desde 1 c�ntimo por minuto.
http://es.voice.yahoo.com


------------------------------------------------------------------------------


_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user