Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to check if recordset is empty

 
david luis
Ranch Hand
Posts: 53
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a piece of code where I check if my recordset is empty. I use these function:



The problem that I have with these function is that when I show the results of recordset the first register dont show. I suspect that is because the "rsCheck.next"
If I put rsCheck.first(), gives me an exception.

Could you help me please?
 
Knute Snortum
Bartender
Pie
Posts: 2908
62
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you should be using one of the "get" methods.
 
david luis
Ranch Hand
Posts: 53
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:I think you should be using one of the "get" methods.


I dont understand you, sorry :-(
 
K. Tsang
Bartender
Posts: 3585
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may just want to use



This way you don't need to set your result set back to the first row.
 
Knute Snortum
Bartender
Pie
Posts: 2908
62
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the documentation for RecordSet. Several of the methods start with the letters "get", like getString(int).
 
Dave Tolls
Ranch Hand
Posts: 2112
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would question why you need to know whether the RS is empty prior to looping over its contents.
Surely it's easier to check if there were any results after you've read them?
 
Campbell Ritchie
Sheriff
Posts: 51453
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RecordSet? You would appear to mean ResultSet.

Look in the Java Tutorials. The first example shown tests whether the ResultSet it has been given is full or not. Beware: the method used there to find whether a result set is full has a side‑effect.

I think this discussion would fit better in our databases forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic