ResultSet inside and outside movement
@author Ixenos
Movement of the cursor within and outside the moving finger
Inside movement is a resultset to get the cursor after that!
Outer movement is the iteration of multiple resultset
Inside move
A generic database does not allow a single query to submit multiple SELECT statements.
1.execute executes the SQL statement and returns a result set of resultset,
2. There is a cursor next in front of the first tuple (imagine), call Hasnext will determine the cursor next to a tuple does not exist
3.rs.next Locating rows (tuple triple), Rs.getxxx Locating Columns (field fields)
Move outside
Multiple result sets may be returned in the execution of a stored procedure, or in some operations that allow a single query to submit multiple SELECT statements
1. Execute the SQL statement using the Execute method to get the first result set or update count,
2. Call the Getmoreresults method repeatedly, move the resultsets cursor to the next result set,
3. When there are no more result sets or update counts, complete the operation
4.stat.getresultset locates the current result set, stat.getupdatestatement the update count, Stat.getmoreresults locates the next result set
Boolean isresult = Stat.execute (sql); Boolean done = False;while (!done) { if (isresult) { ResultSet result = Stat.getresultset (); }else{ int updatecount = Stat.getupdatecount (); Isresult is false, but count! =-1, stating that there is a SQL operation but does not return a result set if (updatecount >= 0) { ... }else{ //count is-1, the description getmoreresults has no result set, and there is no other SQL operation, at which time quit done = true;} } if (!done) Isresult = Stat.getmoreresults ();}
Java EE JDBC resultset internal and external movement