This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hey guys Just wondering if java developers have decided kindly to offer a method that checks if resultSet is empty or not!!?
I searched in this forum and others for this problem, but unfortunately almost all replies tells the OP to use rs.next() and this method although will return false if the resultset is empty BUT it will move the curser down one record!
Another solution that was suggested is using rs.wasNull, and you have to get the record before you can check whether it was null or not!
Furthermore, it was suggested that you place a counter within while(re.next()) and then check whether the counter is 0. Unfortunately this doesn't apply in my case, because I need to add a text to my document (that shall be displayed in TextArea) before I can loop through the records in the resultSet and add them to this document....
So I need to check if the resultSet is empty before I can proceed in adding values to the document!
any help greatly appreciated thanks HannaH [ January 29, 2006: Message edited by: H Melua ]
Now I'm here, I would recommend Ulf's code over using a scrollable result set. The latter may have a negative impact on performance, as the database server cannot discard results as soon as it moves on - it needs to be able to restore them until the result set is closed. Compare it to reading a file line by line. If you need to go back to previous lines you'll need to store them. If you don't then all you need is the current line.