Escape an access table name containing a question mark with ODBC

淺唱寂寞╮ 提交于 2021-01-27 17:33:50

问题


I have an Access database to query as follows:

id - name - Print? 
1  - one  - Yes
2  - two  - No

Now my query in java, using the PreparedStatement with an ODBC connector goes something like this:

select * from table where [Print?] = Yes

I can't find a way around this to escape the question mark. I know it's an awful design choice by whoever made the database, but it's so tied in applications already changing it is not an option.

PS. I've read How to query for a MS Access column whose name has a question mark, via ODBC? but this did not answer my question.


回答1:


As suggested in the comments to the question, apparently the only workaround is to either

  • rename the column in the Access table to remove the question mark, or

  • create a saved query in Access to return the column with a different name, and then run your JDBC operations against the query, not the table.



来源:https://stackoverflow.com/questions/18593415/escape-an-access-table-name-containing-a-question-mark-with-odbc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!