Re: <p><pre><font size="3">Question on PreparedStatement.executeQuery()<br>that returns a ResultSet.</font></pre></p>
Posted By:
Bozidar_Dangubic
Posted On:
Thursday, February 7, 2002 07:25 AM
executeQuery() should not throw this exception unless you are using the Connection that is currently in use. Regardless of how many record(s) are returned and stored in the result set object (0 to many) this call will not throw an exception. Exception are reserved for when something goes awry. A query that returns nothing does not indicate the Exception. it simply indicates that no records in the database satisfy the search criteria provided in the query. after the call to executeQuery() you can test if there is any data returned by calling rs.next(). if this call returns false, it means that there is no data in the ResultSet, i.e. you query did not produce any errors. Counting before executing is very wasteful. So check and make sure that the Connection object you are using is not currently in use. I have gotten this same exception at times when I accidentally reused the connection that was in the middle of execution or had a ResultSet bound to it.
Re: <p><pre><font size="3">Question on PreparedStatement.executeQuery()<br>that returns a ResultSet.</font></pre></p>
Posted By:
Bozidar_Dangubic
Posted On:
Thursday, February 7, 2002 07:25 AM
executeQuery() should not throw this exception unless you are using the Connection that is currently in use. Regardless of how many record(s) are returned and stored in the result set object (0 to many) this call will not throw an exception. Exception are reserved for when something goes awry. A query that returns nothing does not indicate the Exception. it simply indicates that no records in the database satisfy the search criteria provided in the query. after the call to executeQuery() you can test if there is any data returned by calling rs.next(). if this call returns false, it means that there is no data in the ResultSet, i.e. you query did not produce any errors. Counting before executing is very wasteful. So check and make sure that the Connection object you are using is not currently in use. I have gotten this same exception at times when I accidentally reused the connection that was in the middle of execution or had a ResultSet bound to it.
Re: <p><pre><font size="3">Question on PreparedStatement.executeQuery()<br>that returns a ResultSet.</font></pre></p>
Posted By:
Bozidar_Dangubic
Posted On:
Thursday, February 7, 2002 07:25 AM
executeQuery() should not throw this exception unless you are using the Connection that is currently in use. Regardless of how many record(s) are returned and stored in the result set object (0 to many) this call will not throw an exception. Exception are reserved for when something goes awry. A query that returns nothing does not indicate the Exception. it simply indicates that no records in the database satisfy the search criteria provided in the query. after the call to executeQuery() you can test if there is any data returned by calling rs.next(). if this call returns false, it means that there is no data in the ResultSet, i.e. you query did not produce any errors. Counting before executing is very wasteful. So check and make sure that the Connection object you are using is not currently in use. I have gotten this same exception at times when I accidentally reused the connection that was in the middle of execution or had a ResultSet bound to it.
Re: Question on PreparedStatement.executeQuery()that returns a ResultSet.
Posted By:
Benoit_Quintin
Posted On:
Thursday, February 7, 2002 06:21 AM
I would check the ResultSet's MetaData for info on your data.
Also, you might want to "select count(*) from TABLE" before passing your query to your DB....