Okay. I was wrong in my earlier post.
if ( rs.first() == false ) {....}
That will check for a null query.
Okay. But now for the goofy part. This will move the recordset from BEFORE the First Record to the First Record. Make sense? So now, when you do your while rs.next(), it will start where? The SECOND record.
Solution: put rs.beforeFirst(); BEFORE your while rs.next() and it will start right back at the beginning.
It was incredibly painful to find this simple information. Why Java doesn’t have a RecordSet.Count or something along those lines, I just do not know. It’s stupid. That’s right. STUPID. You simply have to be easily be able to check for null queries. How else can you have dynamic, database-driven sites with conditional logic?
Thanks to Nash Foster for the help in figuring this out. He dug up the information that was freaking buried at the Java Sun Site.
Tagged As Coding, Java Server Pages
Comments are Open (1)
Posted at 12:00 PM
Comments
some student
Thank you for this incredible info, I have been staring in frustration at some JSP code i've been writingfor the past ... 5 hours, wondering why i can't find any way to evaluate whether my SQL query was returning null or not... And now I have a way to do it. I agree, it's incredibly STUPID that there is no simpler way to do it.
Thanks very much for the info.
Posted by: some student | April 28, 2005 01:28 AM