If I am running the following piece of code rs.next should return values starting from the first row of the table instead its returning the values from second row.
String val = "select bl.book_id,bl.branch_id, bl.card_no,bl.date_out, bl.due_date ,concat(b.fname,' ',b.lname) as borrower from book_loans bl inner join borrower b on bl.card_no=b.card_no where bl.book_id like '%"+lm.getBook_id()+"%' and bl.card_no like '%"+lm.getCard()+"%'";
rs=st.executeQuery(val);
if(rs.next())
{
for(int a=0;rs.next();a++)
{
System.out.println("hello# "+a);
lm.book_ids.add(rs.getString(1));
lm.branch_id.add(rs.getInt(2));
lm.cards.add(rs.getString(3));
lm.date_out.add(rs.getString(4));
lm.due_date.add(rs.getString(5));
}
for(int a=0;a<lm.branch_id.size();a++)
{
System.out.println(lm.book_ids.get(a));
System.out.println(lm.branch_id.get(a));
System.out.println(lm.cards.get(a));
System.out.println(lm.date_out.get(a));
System.out.println(lm.due_date.get(a));
}
return 1;
}
return 2;
I am running the exact query in MySQL and its giving the proper value but its not in this code. Its showing in sql
Book ID Branch ID Card No Date Out Due Date
72127317 1 9009 2013-11-25 2013-12-09
72127317 3 9009 2013-11-25 2013-12-09
and in here its retuning as follows
hello# 0 72127317 3 9009 2013-11-25 2013-12-09