Reputation: 909
I use Java with a MySQL database and when I try to run a test I got message :
org.dbunit.dataset.DataSetException: java.sql.SQLSyntaxErrorException: Unknown table 'my_table' in information_schema
It's look like DbUnit can't access to metadata of the table. Do you have any idea ?
Thanks
Upvotes: 0
Views: 1532
Reputation: 31
I have encounter same problem. It seems that current version of DBUnit
(2.6.0) is not compatibility with latest version of mysql-connector-java
. I fixed it by change the version of mysql-connector-java
to 5.*.*
.
If it doesn't work. You could try to specify the schema yourself. To do it, you need to create a IDataBaseConnection
bean
@Bean("mysqlTestSource")
public IDatabaseConnection databaseConnection(DataSource dataSource) throws SQLException, DatabaseUnitException {
return new MySqlConnection(dataSource.getConnection(), YOUR_SCHEMA_NAME);
}
And then ask DBUnit to use this connection by adding this annotation to your test class
@DbUnitConfiguration(databaseConnection = "mysqlTestSource")
Hope it helps.
Upvotes: 3
Reputation: 953
Probably a schema confusion problem - the AmbiguousTableNameException FAQ entry should resolve it.
Upvotes: 1