我的代码如下:
string query = select COUNT(*) from TRACKER where TYPE = ? and LAST_MODIFIED_TIME > LAST_RETREIVED_TIME;
prepStmt = connection.prepareStatement(query);
prepStmt.setString(1, "xml");
resultset = prepStmt.executeQuery();
resultset.next();
int rowcount = resultset.getInt("COUNT(*)");
在数据库中,我有1行用于上述查询但在代码中我得到rowcount = 0。 有什么帮助吗?
答案 0 :(得分:1)
尝试为count(*)
提供别名:
String query = "select COUNT(*) as count from TRACKER where TYPE = ?"+
" and LAST_MODIFIED_TIME > LAST_RETREIVED_TIME";
prepStmt = connection.prepareStatement(query);
prepStmt.setString(1, "xml");
resultset = prepStmt.executeQuery();
resultset.next();
int rowcount = resultset.getInt("count");