File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Will jdbc Prepared Statement's executeQuery ever return null.

 
Shankar Raj
Greenhorn
Posts: 4
  • 0
  • 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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • 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: 33694
316
Eclipse IDE Java VI Editor
  • 0
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic