I am connecting to a DB2 database (DB2 v9.7.400.501) from my Java web application using the IBM DB2 Type 4 driver (db2jcc4.jar). When I try to execute an SQL statement like this,
SELECT * FROM USERS WHERE UPPER(USERNAME) = UPPER('testuser');
I get the following exception:
com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=;;= UPPER('testuser');END-OF-STATEMENT, DRIVER=4.12.55
The problem is from the UPPER
function since, a normal select statement executes normally.
Maybe you should use is this way:
SELECT * FROM USERS WHERE UPPER(USERNAME) LIKE UPPER('testuser');
Your code with '=' is seems ok for SQLite but don't know anbout db2.
UPD. After some investigation, I can say that error is cause by Java code which tries to execute multiple statements in one query using ';' as a delimiter. You should try using the PreparedStatement, addBatch() and executeBatch() for multiple statements.
UPD2. This is DB2 related issue. PostgreSQL, afaik, allows multiple statements in single query.