问题
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