Here is the sample method is given which is retuning the database values with the arraylist in which the for loop is used to execute the query multiple time.
public ArrayList
ArrayList
MYSQLConnect connect=new MYSQLConnect();
Connection conn = connect.connection;
Statement smt = conn.createStatement();
ResultSet rs = null;
//write select query for checking password
for(int i=0;i
{
String query="select SUM(attendance) As presenty,count(attendance)as
total,SUM(attendance)/count(attendance)*100 as percentage
from attendance where gr_number='"+grNumber[i]+"' and (Date
between '"+datefrom+"' and '"+dateto+"') order by `date` ";
rs=smt.executeQuery(query);
while(rs.next()== true){
StudentDetailsForm form =new StudentDetailsForm();
form.setPresentdays(rs.getInt("presenty"));
form.setTotaldays(rs.getInt("total"));
form.setAverage(rs.getInt("percentage"));
System.out.println(rs.getInt("percentage"));
list.add(form);
}
}
smt.close();
rs.close();
conn.close();
return list;
}
No comments:
Post a Comment