public ResultSet executeQuery(String sql) throws SQLException
Returns:
a ResultSet object that contains the data produced by the given query; never null
Throws:
SQLException - if a database access error occurs or the given SQL statement produces anything other than a single ResultSet object
所以,依据 API 的解释,dataResultSet 是永远不会为空的.另外,如果权限有问题或者是 sql 语句有误,会抛出异常.最后,如果没有数据或没有符合条件的数据,那末 dataResultSet 的值不为空.
最后,你要用好 ResultSet.next() 来判断位置.
public boolean next() throws SQLException
Returns:
true if the new current row is valid; false if there are no more rows