Re: NoSuchTableException

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: NoSuchTableException

Matthias Gommeringer
Hi Alexander,

sorry for the long delay. I could reproduce your problem. If you check your logs do you see a message like the following one?

13.06.2009 23:39:25 org.dbunit.database.DatabaseTableMetaData getColumns
WARNUNG: No columns found for table 'xxx' that are supported by dbunit. Will return an empty column list

This shows that your custom configuration of the DatabaseConfig did not work. The problem lies in the IDatabaseTester design - in your case in the JdbcDatabaseTester. The method JdbcDatabaseTester.getConnection() will return a new connection for every single invocation which is why you DatabaseConfig settings will not be valid for the CLEAN_INSERT later (it retrieves a new connection). A solution for this is to override the "IDatabaseTester.getConnection()" method and to set your custom config on all created IDatabaseConnection objects:

HTH,
matthias


    public void testDBUnit() {
        try {
            IDatabaseTester dataTester = new JdbcDatabaseTester(driverClass,
                    connectionUrl, username, password, schema) {

                public IDatabaseConnection getConnection()
                        throws Exception {
                    IDatabaseConnection c = super.getConnection();
                    DatabaseConfig config = c.getConfig();
                    config.setProperty(DatabaseConfig.PROPERTY_METADATA_HANDLER,
                            new MySqlMetadataHandler());
                    config.setFeature(
                            DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES, true);
                    return c;
                }
               
            };

            IDataSet dataSet = new XmlDataSet(getClass().getResourceAsStream("task-dataset.xml"));
            DatabaseOperation.CLEAN_INSERT.execute(dataTester.getConnection(),
                    dataSet);

        } catch (Exception e) {
            e.printStackTrace();
            Assert.fail();
        }

    }






> -----Urspr├╝ngliche Nachricht-----
> Von: "Alexander Okunevich" <[hidden email]>
> Gesendet: 05.06.09 09:33:56
> An: [hidden email]
> Betreff: Re: [dbunit-user] NoSuchTableException


> > Hm, no there is no FEATURE_CASE_SENSITIVE_column_NAMES in dbunit...could you please provide a unit test that lets me reproduce this behavior?
>
>
> MySQL server:
> mysql.exe  Ver 14.14 Distrib 5.1.34, for Win32 (ia32)
>
> DbUnit version 2.4.5
>
> SQL for creating table:
>
> CREATE TABLE `xxx` (
>   `column1` int(11) NOT NULL DEFAULT '0',
>   PRIMARY KEY (`column1`)
> ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
>
> mydataset.xml:
>
> <!DOCTYPE dataset SYSTEM "dataset.dtd">
> <dataset>
>     <table name="xxx">
>         <column>column1</column>
>         <row>
>             <value>123</value>
>         </row>
>     </table>
> </dataset>
>
>
> unit test:
>
> public class SimpleTest {
>
>     private String driverClass = "com.mysql.jdbc.Driver";
>     private String connectionUrl = "jdbc:mysql://localhost:3306/myschema";
>     private String username = "root";
>     private String password = "p@ssw0rd";
>     private String schema = "myschema";
>
>     @Test
>     public void testDBUnit() {
>         try {
>             IDatabaseTester dataTester = new
> JdbcDatabaseTester(driverClass, connectionUrl, username, password,
> schema);
>
>             DatabaseConfig config = dataTester.getConnection().getConfig();
>             config.setProperty(DatabaseConfig.PROPERTY_METADATA_HANDLER,
> new MySqlMetadataHandler());
>             config.setFeature(DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES,
> true);
>
>             IDataSet dataSet = new XmlDataSet(new
> FileInputStream("task-dataset.xml"));
>
>             DatabaseOperation.CLEAN_INSERT.execute(dataTester.getConnection(),
> dataSet);
>
>         } catch (Exception e) {
>             e.printStackTrace();
>             Assert.fail();
>         }
>
>     }
>
> }
>
> ------------------------------------------------------------------------------
> OpenSolaris 2009.06 is a cutting edge operating system for enterprises
> looking to deploy the next generation of Solaris that includes the latest
> innovations from Sun and the OpenSource community. Download a copy and
> enjoy capabilities such as Networking, Storage and Virtualization.
> Go to: http://p.sf.net/sfu/opensolaris-get
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>


____________________________________________________________
Text: GRATIS f├╝r alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user