database - In Java, Why ResultSet does not allow you to run next() more than 1 time? -
look @ code:
resultset results=preparedstmt.executequery(); while (results.next()){ string subject=results.getstring(1); system.out.println(subject +" 1st time"); } while (results.next()){ string subject=results.getstring(1); system.out.println(subject+ " 2nd time"); }
why system prints out result @ 1st time, & not print out result in second time?
if want run results.next() more 1 time, proper way code?
while( rs.next() )
advance 'current row' cursor end of set.
by default, resultset
read-only , forward only, once end, you'll need call first() start over. note: first()
optional method , may not supported driver.
Comments
Post a Comment