带有“é”的 iSeries JDBC Sql 语句在列名中抛出 java.sql.SQLException: [SQL0104]

发布于 2024-09-18 19:58:34 字数 1913 浏览 5 评论 0原文

我在从 SQL 查询返回的列名中使用字符“é”时遇到问题。 运行此查询

SELECT PRCAT as Categorie, PRYEA as Année, PRDSC as Designation from DEMO.PRODUCT

使用连接到 iSeries 的 IBM Toolbox JDBC 驱动程序

 java.sql.SQLException: [SQL0104] Token é was not valid. Valid tokens: , FROM INTO. Cause . . . . . :   A syntax error was detected at token é.  Token é is not a valid token.  A partial list of valid tokens is , FROM INTO.  This list assumes that the statement is correct up to the token.  The error may be earlier in the statement, but the syntax of the statement appears to be valid up to this point. Recovery  . . . :   Do one or more of the following and try the request again: -- Verify the SQL statement in the area of the token é. Correct the statement.  The error could be a missing comma or quotation mark, it could be a misspelled word, or it could be related to the order of clauses. -- If the error token is <END-OF-STATEMENT>, correct the SQL statement because it does not end with a valid clause.
    at com.ibm.as400.access.JDError.throwSQLException(JDError.java:650)
    at com.ibm.as400.access.JDError.throwSQLException(JDError.java:621)
    at com.ibm.as400.access.AS400JDBCStatement.commonPrepare(AS400JDBCStatement.java:1481)
    at com.ibm.as400.access.AS400JDBCPreparedStatement.<init>(AS400JDBCPreparedStatement.java:185)
    at com.ibm.as400.access.AS400JDBCConnection.prepareStatement(AS400JDBCConnection.java:1903)
    at com.ibm.as400.access.AS400JDBCConnection.prepareStatement(AS400JDBCConnection.java:1726)
...

会产生此异常:这是 jdbc 驱动程序设置不当的问题,还是对可以使用的字符有一些内置限制(我在哪里可以找到这个?我发现IBM doco 简直是迷宫般的......)。我的 jdbc 连接代码如下所示:

Class.forName("com.ibm.as400.access.AS400JDBCDriver").newInstance();
Connection cnnobj=DriverManager.getConnection("jdbc:as400://"+ipAddress+";errors=full;date format=iso;time format=iso;", user, pass);

I am having trouble using the character "é" in a returned column name from an SQL query. Running this query

SELECT PRCAT as Categorie, PRYEA as Année, PRDSC as Designation from DEMO.PRODUCT

using the IBM Toolbox JDBC driver connecting to an iSeries produces this exception:

 java.sql.SQLException: [SQL0104] Token é was not valid. Valid tokens: , FROM INTO. Cause . . . . . :   A syntax error was detected at token é.  Token é is not a valid token.  A partial list of valid tokens is , FROM INTO.  This list assumes that the statement is correct up to the token.  The error may be earlier in the statement, but the syntax of the statement appears to be valid up to this point. Recovery  . . . :   Do one or more of the following and try the request again: -- Verify the SQL statement in the area of the token é. Correct the statement.  The error could be a missing comma or quotation mark, it could be a misspelled word, or it could be related to the order of clauses. -- If the error token is <END-OF-STATEMENT>, correct the SQL statement because it does not end with a valid clause.
    at com.ibm.as400.access.JDError.throwSQLException(JDError.java:650)
    at com.ibm.as400.access.JDError.throwSQLException(JDError.java:621)
    at com.ibm.as400.access.AS400JDBCStatement.commonPrepare(AS400JDBCStatement.java:1481)
    at com.ibm.as400.access.AS400JDBCPreparedStatement.<init>(AS400JDBCPreparedStatement.java:185)
    at com.ibm.as400.access.AS400JDBCConnection.prepareStatement(AS400JDBCConnection.java:1903)
    at com.ibm.as400.access.AS400JDBCConnection.prepareStatement(AS400JDBCConnection.java:1726)
...

Is this an issue of improper jdbc driver setup, or is there some built in limitation to what characters can be used (and where can I find this? I find IBM doco impossibly labyrinthine...). My jdbc connection code looks like this:

Class.forName("com.ibm.as400.access.AS400JDBCDriver").newInstance();
Connection cnnobj=DriverManager.getConnection("jdbc:as400://"+ipAddress+";errors=full;date format=iso;time format=iso;", user, pass);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖树树初阳… 2024-09-25 19:58:34

如果引用别名会发生什么?

SELECT PRCAT as Categorie, PRYEA as "Année", PRDSC as Designation from DEMO.PRODUCT

What happens if you quote the alias name?

SELECT PRCAT as Categorie, PRYEA as "Année", PRDSC as Designation from DEMO.PRODUCT
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文