Bug #3213 Need an efficient JDBC way to discard the remaining records of a resultsets
Submitted: 17 Mar 2004 13:52 Modified: 17 Mar 2004 14:07
Reporter: Christian Ouellet Email Updates:
Status: Won't fix Impact on me:
None 
Category:Connector / J Severity:S4 (Feature request)
Version:3.0.11 OS:Any (All)
Assigned to: CPU Architecture:Any

[17 Mar 2004 13:52] Christian Ouellet
Description:
I use code that do statement like

SELECT * FROM TABLEX

only to retrieve a ResultSetMetaData.

I am using a third-party proprietary library, then I cannot add a "top 1 row" to the statement.  Could it be possible to implement something to discard the remaining results when closing a streaming resultset instead of reading them all? When using large tables, it makes client slow and memomy hungry.

How to repeat:
execute a query like "select * from tablex" on a large table.

Suggested fix:
Send a message to the server to discards remaining results instead of reading them alls.
[17 Mar 2004 14:07] Mark Matthews
Other than closing the connection itself, there is no way to read the rest of the rows. The server has already sent them, so until they're at least pulled off the wire, you can't do anything else.

Have you looked at using Statement.setMaxRows(), or alternatively, if you can alter the query, adding a where clause that evaluates to false, e.g. ' AND 1=2', which will cause the query to return no rows?