I have resolved the same problem using the below code:
String query = "SELECT violationDate, COUNT(*) as date " +
"FROM challan " +
"WHERE challanType = '" + type + "' GROUP BY violationDate";
Here violationDate and date are two columns of the result table. date column will return occurrence.
cr.getInt(1)