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

Is it ok to use PreparedStatement when there are no positional parameters?

 
Sourabh Bawage
Ranch Hand
Posts: 33
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


is there any harm/performance hit to use PreparedStatement instead of Statement when there are no positional parameters???
 
Ashwini Kashyap
Ranch Hand
Posts: 90
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no harm in doing so.
PreparedStatement can be used for SQL with no parameters (we use Statement) but mostly they are used for SQL statements that take parameters.

For further reference you may see url.

Thanks,
Ashwini Kashyap | www.infocepts.com
 
Claude Moore
Ranch Hand
Posts: 829
7
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moreover, using PreparedStatement may improve performance because target DBMS may cache native translation of the statement and reuse it, instead of re-translating each time. Of course the details are very specific for every DBMS.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic