MySQLSyntaxErrorException when column name is 'key'

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

MySQLSyntaxErrorException when column name is 'key'

Hi, I'm trying to dump some data to file using FlatXmlDataSet.write() but it fails due to a certain table has a column called 'key':

Exception in thread "main" org.dbunit.dataset.
DataSetException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key from entrytype order by id' at line 1
    at org.dbunit.database.DatabaseDataSet.getTable(
    at org.dbunit.database.DatabaseTableIterator.getTable(
    at org.dbunit.dataset.xml.FlatXmlWriter.write(
    at org.dbunit.dataset.xml.FlatXmlDataSet.write(

I get the same error in MySql Query Browser using this select:
select id, key from entrytype order by id;

However, if I use an alias 'e' it works:
select, e.key from entrytype e order by;

Is there a way to achieve something similar in DbUnit?

WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today.  Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
dbunit-user mailing list
[hidden email]