A few things to check…
Look into the parameters for your ODBC connection. In particular, the Library List and Naming Convention. If naming convention is *SYS rather than *SQL and you are separating the library and file with a period, that could be a problem. Likewise, if the library list is not properly set (or it is *USRLIBL, but the library is not in *USRLIBL), you could have errors:
Also, you could do yourself a favor and look into IBM’s provider, iDB2Connection for better performance:
Lastly, when having difficulty with more complex SQL statements, you may want to pare it down to bare bones if you’re not getting enough feedback from the error message to isolate the issue. Get it working in slimmed-down form, then build it back up until you hit the error. Using this approach can help you identify the problem. Of course, if the problem IS with the library list, naming convention, user id, password, etc. it is going to hit the wall regardless of how much you simplify it.