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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -