How to get only the first row from a java.sql.ResultSet?

Posted by llm on Stack Overflow See other posts from Stack Overflow or by llm
Published on 2010-04-19T13:55:29Z Indexed on 2010/04/19 14:13 UTC
Read the original article Hit count: 213

Filed under:
|

I have a ResultSet object containing all the rows returned from an sql query.

I want to be able to (in the java code, NOT force it in the SQL) to be able to take a ResultSet and transform it so that it only contains 1 (the first) row.

What would be the way to acheive this? Also, is there another appropriate class (somewhere in java.sql or elsewhere) for storing just a single row rather than trimming my ResultSet?

Thanks!

© Stack Overflow or respective owner

Related posts about java

Related posts about jdbc