在java里,用的db2数据库
String sql="SELECT count(*) FROM table";
int i=0;
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
i=rs.getInt(1);
System.out.println(i);
}
运行出现如下错误:
com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -243, SQLSTATE: 36001, SQLERRMC: SQL_CURSH200C1
at com.ibm.db2.jcc.b.sf.e(sf.java:1680)
at com.ibm.db2.jcc.b.sf.a(sf.java:1239)
at com.ibm.db2.jcc.c.jb.h(jb.java:139)
at com.ibm.db2.jcc.c.jb.a(jb.java:43)
at com.ibm.db2.jcc.c.w.a(w.java:30)
at com.ibm.db2.jcc.c.cc.f(cc.java:161)
at com.ibm.db2.jcc.b.sf.n(sf.java:1219)
at com.ibm.db2.jcc.b.sf.a(sf.java:1957)
at com.ibm.db2.jcc.b.sf.a(sf.java:523)
at com.ibm.db2.jcc.b.sf.executeQuery(sf.java:507)
at checkenrol.testCon.main(testCon.java:36)
请大家帮忙看看是什么原因
------解决方案--------------------------------------------------------
直接在DB2中运行此语句是否正确?
------解决方案--------------------------------------------------------
at com.ibm.db2.jcc.b.sf.executeQuery(sf.java:507)
显然这个sql语句有问题
SELECT count(*) FROM table
table可是关键字啊。你要查的真实表名是什么?
------解决方案--------------------------------------------------------
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE