Tuesday, November 15, 2011

DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=;;

If you get below mentioned error


Exception in thread "main" com.ibm.db2.jcc.b.eo: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=;;SCHEMA.TABLE_NAME;END-OF-STATEMENT, DRIVER=3.53.95
        at com.ibm.db2.jcc.b.bd.a(bd.java:676)
        at com.ibm.db2.jcc.b.bd.a(bd.java:60)
        at com.ibm.db2.jcc.b.bd.a(bd.java:127)
        at com.ibm.db2.jcc.b.gm.c(gm.java:2484)
        at com.ibm.db2.jcc.b.gm.d(gm.java:2461)
        at com.ibm.db2.jcc.b.gm.a(gm.java:1962)
        at com.ibm.db2.jcc.t4.db.g(db.java:138)
        at com.ibm.db2.jcc.t4.db.a(db.java:38)
        at com.ibm.db2.jcc.t4.t.a(t.java:32)
        at com.ibm.db2.jcc.t4.sb.h(sb.java:141)
        at com.ibm.db2.jcc.b.gm.bb(gm.java:1933)
        at com.ibm.db2.jcc.b.gm.a(gm.java:2799)
        at com.ibm.db2.jcc.b.gm.a(gm.java:604)
        at com.ibm.db2.jcc.b.gm.executeQuery(gm.java:588)




Possible reason could be SYNTAX error. Please make sure all syntax are correct upto DB2 standard. Verify the syntax of your query. Even don't add  semi-colon (;) at the end of the query.

In this case if you are using DB2 Universal Driver. 

Syntax :

Class.forName("com.ibm.db2.jcc.DB2Driver");
Connection con=DriverManager.getConnection("jdbc:db2://hostname:port/Schema","username","password");


Jar file : db2jcc.jar

To download Jar files : Click here