Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about Null in ResultSet

 
saravana kumar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends,
i needs ur help. how to check wheather Result is null or Not.i have written a query which is selecting data from table with one condition. if there is none of a record satisfied the condition it should be returned null. how to check that one? any one knows please let me know with example.

thanks a lot friends...
saran
 
sandeep balyan
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use
if(ResultSet.next())
{
do this
}
else
{
do that
}

njoy
regds
 
Nandkishore Dhilde
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or you can do after firing query
int rowcount = rs.getRow(); //rs is ResultSet object
if(rowcount ==0) // then ur query returns null result and if more than 0 then go for rs.next()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic