Topic
  • No replies
SystemAdmin
SystemAdmin
14225 Posts

Pinned topic .SqlSyntaxErrorException: Error: SQLCODE=-204 ,SQLSATATE=42704

‏2013-02-19T13:30:41Z |
please please help me getting the following error
com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-204,SQLSATATE=42704

when trying to run
package test;

import java.sql.*;
import java.util.*;
import com.ibm.db2.jcc.*;
public class Wrk_db {

public static void main(String[] args) {
Connection con = null;
Statement st = null;
ResultSet rs = null;
String url = "jdbc:db2://localhost:50000/COMPANY";
String user = "db2admin";
String password = "123456";

try
{
Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
con = DriverManager.getConnection(url, user, password);
String query = "SELECT WORK_NAME FROM WORKDB";
st = con.createStatement();
rs = st.executeQuery( query);//showing error at this line

while (rs.next()) {

System.out.println(rs.getString(1));

} }
catch (SQLException e) {
System.out.println(e.getMessage());
System.out.println(e.getErrorCode());
e.printStackTrace();
}

catch (Exception e) {
e.printStackTrace();
}
finally
{
try{
st.close();
con.close();

}
catch(Exception e)
{
e.printStackTrace();
System.exit(1);
}
}
}

}