An error that occurs when a SELECT statement is first executed prevents a ResultSet object from being opened on it. The same error does not close the ResultSet if it occurs after the ResultSet has been opened.
For example, a divide-by-zero error that happens while the executeQuery method is called on a java.sql.Statement or java.sql.PreparedStatement throws an exception and returns no result set at all, while if the same error happens while the next method is called on a ResultSet object, it does not cause the result set to be closed.
Errors can happen when a ResultSet is first being created if the system partially executes the query before the first row is fetched. This can happen on any query that uses more than one table and on queries that use aggregates, GROUP BY, ORDER BY, DISTINCT, or UNION.
Closing a Statement causes all open ResultSet objects on that statement to be closed as well.
The cursor name for the cursor of a ResultSet can be set before the statement is executed. However, once it is executed, the cursor name cannot be altered.
Table of Contents