java - Connection with DB2 and jdbc? -
i trying connect db2 using below code getting following exception
com.ibm.db2.jcc.am.sqlsyntaxerrorexception: db2 sql error: sqlcode=-204, sqlstate=42704, sqlerrmc=root.employee, driver=3.63.123 @ com.ibm.db2.jcc.am.fd.a(fd.java:679) @ com.ibm.db2.jcc.am.fd.a(fd.java:60) @ com.ibm.db2.jcc.am.fd.a(fd.java:127) @ com.ibm.db2.jcc.am.ho.c(ho.java:2644) @ com.ibm.db2.jcc.am.ho.d(ho.java:2632) @ com.ibm.db2.jcc.am.ho.a(ho.java:2097) @ com.ibm.db2.jcc.t4.cb.h(cb.java:141) @ com.ibm.db2.jcc.t4.cb.b(cb.java:41) @ com.ibm.db2.jcc.t4.q.a(q.java:32) @ com.ibm.db2.jcc.t4.sb.i(sb.java:135) @ com.ibm.db2.jcc.am.ho.gb(ho.java:2066) @ com.ibm.db2.jcc.am.ho.a(ho.java:3120) @ com.ibm.db2.jcc.am.ho.a(ho.java:681) @ com.ibm.db2.jcc.am.ho.executequery(ho.java:665)
code:
class.forname("com.ibm.db2.jcc.db2driver"); system.out.println("**** loaded jdbc driver"); string url = bundle.getstring("db2.url"); string user = bundle.getstring("db2.username"); string password = bundle.getstring("db2.password"); // create connection using ibm data server driver jdbc , sqlj connection con = drivermanager.getconnection (url, user, password); // commit changes manually con.setautocommit(false); system.out.println("**** created jdbc connection data source"); // create statement statement stmt = con.createstatement(); system.out.println("**** created jdbc statement object"); // execute query , generate resultset instance resultset rs = stmt.executequery("select empno employee"); system.out.println("**** created jdbc resultset object"); string empno; // print of employee numbers standard output device while (rs.next()) { empno = rs.getstring(1); system.out.println("employee number = " + empno); } system.out.println("**** fetched rows jdbc resultset"); // close resultset rs.close(); system.out.println("**** closed jdbc resultset"); // close statement stmt.close(); system.out.println("**** closed jdbc statement"); if(con!=null){system.out.println("connection successfull db2");}
the problem not connection. need understand how read db2 error messages.
in part problem explained:
sqlcode=-204, sqlstate=42704, sqlerrmc=root.employee
in means, established connection, , when looking object root.employee
, db2 did not find anything. error 204, can interpreted sql0204. in db2clp or internet , got answer.
it seems problem connecting root database, , implicit schema 'root' not contain employee table. make sure using right schema.
Comments
Post a Comment