mercredi 25 février 2015

UcanaccessSQLException



I am converting an existing program from JDBC-ODBC Bridge to UCanAccess. It has been working for years. The Java program writes to an MDB file. After conversion, one Insert command stopped working.

It throws "net.ucanaccess.jdbc.UcanaccessSQLException: unexpected token: [".


After some experimentation I determined that the problem is caused by three columns that include apostrophes in their names. Example: [Sched'd PO Place Date]. Apparently JDBC-ODBC Bridge did not care but UCanAccess does.


I am somewhat trapped with the existing MDB structure or I'd simply rename the fields. But there is no telling how many downstream reports could be broken if I did that. The MDB is used for Ad Hoc reporting.


Here is a simplified SQL Select version of the problem. It throws the same error as the Insert. I can send more code if it would be helpful.


String sql4 = "select [Sched'd PO Place Date] from [Tier 1] ";


Is there a way to "escape" the apostrophes or reconfigure ucanaccess so that the driver can execute them?




Aucun commentaire:

Enregistrer un commentaire