[Java JDK]ResultSet.next()

1 JDK

[jdk1.5doc]

Moves the cursor down one row from its current position. A ResultSet cursor is initially positioned before the first row; the first call to the method next makes the first row the current row; the second call makes the second row the current row, and so on. 
If an input stream is open for the current row, a call to the method next will implicitly close it. A ResultSet object's warning chain is cleared when a new row is read. 


Returns:
true if the new current row is valid; false if there are no more rows 
Throws: 
SQLException - if a database access error occurs

2 翻译

将指针移动到当前位置的下一行。
ResultSet 指针的初始位置位于第一行之前;第一次调用next()方法将会把第一行设置为当前行;第二次调用next()方法指针移动到第二行,以此类推。
当对next()方法调用返回 false,说明此时指针位于最后一行之后。所有对 ResultSet 需要使用当前行的方法[注:如getString()、getInt()等等]的调用都将导致next()方法抛出 SQLException 异常。如果返回的 ResultSet 集合的类型被设置为 TYPE_FORWARD_ONLY ,会在随后对next()方法的调用中返回 false 或抛出 SQLException 异常,因不同的数据库提供者的 JDBC 驱动实现而异。
如果为当前行打开了一个输入流,对next()方法的调用将会隐式地关闭它。
当新的一行读入时,ResultSet对象的警告链将被清空。

返回值:
如果新的当前行有效,则为true;如果没有更多的行,则为false
异常:
如果出现数据库访问错误

原文地址:https://www.cnblogs.com/johnnyzen/p/13895000.html