At line #20... if (rs.next()) - the resultset contains a record, rs.next() returns true (I checked using a breakpoint), but the statements in the if block are not executed. The code jumps immediately to the finally block.
This is happening in several (new) methods I've written, but older methods containing similar logic / syntax are working fine.
Hi, Jeanne... thanks for the response (and the welcome)!
I agree, my expectation is (as you pointed out) that I'll always get a RecordCount returned from this query, even if there are no matching records... and I am.
To reiterate, I put a breakpoint at line 20, examined the value of the expression rs.next()... it's true. But when I continue execution (step over), it doesn't execute the next statement in the if block... it jumps directly to the finally block. Seems impossible (!)... but that's what it's doing, consistently.
Using Eclipse JEE (Ganymede), app is deployed on JBoss 4.2.2, Oracle back end. No errors in JBoss log, no exceptions, no nothing... just weird. I've showed the behavior to a couple of other guys here, we're all scratching our heads. I've redeployed (many times), restarted JBoss, rebooted the server... no luck resolving this. Been fighting it for days...
BTW, this is a DAO class... and, as you can see, the connection is method-scoped. Also, I've copied the strSQL variable (while in break mode), pasted into Toad & executed... worked fine, returned a RecordCount of value 2 (or other value, depending on userSsn). I just can't get the code to continue executing the statements inside the if block...
Joined: Sep 15, 2009
I put println statements in the if block and the catch block - not executing either of 'em. <sigh>
I'm playing around with Connection scoping, now... I wonder if using these similarly-named connections / statements / resultsets within multiple methods, within multiple DAO's might be introducing a conflict?
try catching Throwable just as an experiment. Maybe you're getting a runtime exception thats not being caught.
On a side note, you should also put an independent try/catch around each "close()" statement. If one of your close statements throws an exception it will not finish the rest of your cleanup, and you will be leaking resources.
subject: rs.next() returns true, but if (rs.next()) block not executed