Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Set string parameter to Prepared Statement

 
Anirudha Joshi
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am constructing a DAO which uses PreparedStatement to retrive data. DAO calls back different methods on the calling application to get SQL query, its parameters and other details (which are required to construct statement). Input parameter data types can be Int, Long or String.

As a common approach, can call call setString on all input parameters? Does it have any performance issue?

Anirudha
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 35976
422
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anirudha,
Yes, you can call setString() in all those cases. There might be a slight performance hit (if one at all), but not enough to worry about. Compared to the query and response time, it would be nothing.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!