0

我有以下代码:

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。有什么帮助吗?

4

1 回答 1

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"); 
于 2013-07-03T07:37:11.313 回答