Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Check That a query returns exactly one row

843854Oct 14 2003 — edited Oct 16 2003
I have to check that a statment return exactly one row before i can use the result of it. I must use the following parameters for the result set : ResultSet.TYPE_FORWARD_ONLY and ResultSet.CONCUR_READ_ONLY. Here is the way i think code it.

private void sqlprimCheckUniqueResultSet(ResultSet rs)
throws NoRowException, NotUniqueRowException {
try {
if (!rs.next()) {
throw new NoRowException();
}
if (rs.next()) {
throw new NotUniqueRowException();
}
rs = ((PreparedStatement)rs.getStatement()).executeQuery();
if (!rs.next()) {
throw new NoRowException();
}
} catch (SQLException e) {
throw ErrorHandler.rethrow(e, "......");
}
}

Is it good ? Someone have any advices ?

Thanks

claude.catonio@winterthur.be


Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 13 2003
Added on Oct 14 2003
6 comments
120 views