结果集中没有数据

时间:2013-07-03 07:30:54

标签: java resultset

我的代码如下:

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

1 个答案:

答案 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");