File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Prepared statements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Prepared statements" Watch "Prepared statements" New topic
Author

Prepared statements

Yasir Qureshi
Greenhorn

Joined: Apr 26, 2006
Posts: 24
Hi,
I am using preapared statments, I was just wondering what if my in clause is dynamic, I am passing CSV values in my 'in' clause and not calling .set methods, for example

select a.* from A a where a.id in (params)
Params is string that is dynamically generated and its a CSV not string having question marks, i.e.: (1,2,3) not (?,?,?)

In this case will this query be considered as a single query and compiled once or it is considered separate query and compile every time.

Thanks in advance,
Yasir.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2504
    
    8

It's a separate query each time you send a unique combination of parameters.
But your query is so simple that the analyze and compile cost / time can't be a lot.

Regards, Jan


OCUP UML fundamental and ITIL foundation
youtube channel
Yasir Qureshi
Greenhorn

Joined: Apr 26, 2006
Posts: 24
Thank for reply Jan, so it means in this case using Prepared statement is not going to make very big difference.

Yasir.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30795
    
157

"Yasir",

We're pleased to have you here with us here at JavaRanch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character.

Thanks,
Jeanne
Forum Bartender


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Prepared statements