Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Well, perhaps stating the obvious: if you have an empty (no rows) result set, that first "if (rsa.next())" will return false, and you'll get to that one condition that doesn't print anything. Several of those other conditions would throw a NullPointerException if getString() were ever to return null, as you're anticipating.
Originally posted by Steve Dyke: Then why do I get an output of:
System.out.println("Here at ok");
If there is no loop?
What would you suggest to fix this?
You see that output if that column in the first row of the result set contains valid data. The loop referred to would be need to process any additional rows.
As far as how to fix it: depends what the code is trying to do, exactly. If all you need is one value from one row, then just get rid of all the "null" stuff, and have 'if (rsa.next()) { /* THE OK PART */ } else { /* THE EMPTY-RESULT-SET PART */}'
This is my class. What is happening is invalid value is being generated for the sarray[i][1] either a null or empty something and the dataset creater cannot read:
I don't see that you're ever actually checking that the field itself is null, just that a trimmed version of a valid string returned by getString(1) isn't null.
There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James