带有“é”的 iSeries JDBC Sql 语句在列名中抛出 java.sql.SQLException: [SQL0104]
我在从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果引用别名会发生什么?
What happens if you quote the alias name?