views:

87

answers:

1

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);
+1  A: 

What happens if you quote the alias name?

SELECT PRCAT as Categorie, PRYEA as "Année", PRDSC as Designation from DEMO.PRODUCT
Michael Konietzka
by golly, that works!
larson4