Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get the rowCount, and also ResultSet.last() in JDBC?

 
liang gu
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I basically have 2 questions?
1) First, how to get the total row count of a result set without looping through the whole result set?
2) I have the following code:
conn = dataSource.getConnection();
CallableStatement stmt = null;
stmt = conn.prepareCall("BEGIN " + "MyStoredProcedure" + "(?); END;");
stmt.registerOutParameter(1, OracleTypes.CURSOR);
stmt.execute();
ResultSet rs = (ResultSet) stmt.getObject(1);
rs.last() //gives Exception here
When these statements executed, I got SQLException on rs.last(). I have tried to use setFetchDirection() method on rs and stmt, but without any luck.
I urgently need help! Thanks for help!
Liang
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic