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

How to set multiple values in PrepareStatement while using "IN" in the query

 
Gaurav Goyal
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the foll prepared stmt

ps=Connection.prepareStatement(select * from EMPLOYEE
where emp_name IN ? );

Suppose i have 3 names to find "black", "brown" and "green"

what shd I pass to setString method

ps.setString(1,_______);
 
Jan Cumps
Bartender
Posts: 2618
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JavAranch article Batching Select Statements in JDBC by Jeanne Boyarsky proposes some approaches to handle this.

Regards, Jan
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!