0

I have below code:

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(*)"); 

In database i have 1 row for the above query but in code i am getting rowcount= 0. any help?

Aquarius24
  • 1,806
  • 6
  • 33
  • 61

1 Answers1

1

Try giving an alias to the 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"); 
AllTooSir
  • 48,828
  • 16
  • 130
  • 164