Apr 15 22:50:19: dbUtils::dbResultSet2Subscription: rs= com.mysql.jdbc.Resul tSet@6d3b92 Apr 15 22:50:19: rs is NOT before first Apr 15 22:50:19: dbUtils::dbResultSet2Subscription: setting new subscription
***** Exception Apr 15 22:50:19: dbUtils::dbResultSet2Subscription: Illegal operation on emp ty result set. *****
So, rs is not null, is not before first, but when I go to get the columns, it throws that exception.
BTW, in this case, the result set is empty.
-------<br />Thanks & regards,<br />anw
Joined: Sep 04, 2006
The answer: rowset::last() set the cursor on the last row, and returns true if it is a valid row, or false if there are no rows in the result set. Kind of convoluted, setting to last just to see if it's valid, then back to first (or before first) to begin using getNext().
Here's the whole story: I'm designing a general purpose function to use rs to populate an object from a database, so the user could pass in an rs that is before first, or they may have already checked to see if there are rows by doing getNext() first. In particular, if they want a row count, for example to dimensionalize an array, the only way I know to do this is to do a getLast then get the row number, then set rs back to the "beginning". A user could be perfectly reasonable in calling the "beginning" beforeFirst or calling it the first row, and I was trying to accommodate both in this function.
Therefore, in this function, beforeFirst could return false because a) there are no rows, or b) because it is positioned on the first row. In the latter case, getNext() returns false if there is only one row.
I don't know what would happen if you got a false beforeFirst, because it was empty, but then set it to beforeFirst to check getNext.
Anyway, I think that rs not having isEmpty() and rowCount() methods is a big deficiency. I kludged up a rowCount method as described above, and I actually used that, but the key to it was going to getLast().