Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Will jdbc Prepared Statement's executeQuery ever return null.

 
Shankar Raj
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Though Java API says never null. People generally check if (rs!=null) rigt after some rs=ps.executeQuery();
just curious will ever they get rs==null say db was not connecting etc. I presume it would throw exceptions and will never encounter such situations but why do people write this?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shankar Raj wrote:People generally check if (rs!=null) rigt after some rs=ps.executeQuery();

Generally ? Only people who don't read the API do.

[edited to fix quote marks]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe is 100% correct. executeQuery() does not return null. Checking for null is poor practice and not considered a JDBC idiom.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic