I would like to create a temporary table from a Java application using JDBC 1.2.
I used the following command:
rs=stmt.executeQuery("DECLARE GLOBAL TEMPORARY TABLE tempTable LIKE me.myTable');
But I'm getting the following error message
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token "myTable" was found following "BLE tempTable LIKE me.". Expected tokens may include: "END-OF-STATEMENT". SQLSTATE=42601
First of all, the SQL looks OK. Does it work from the CLP?
It looks like your quotes are wrong on the SQL string. It looks like you have a double quote (") at the front, and a single (') at the end (this maybe just a typo).
I noticed that you are using ExecuteQuery to perform the operation. ExecuteQuery is only for SELECT statements since it returns a result set. Use ExecuteUpdate for all non-SELECT statements, including DDL statements.