File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Prepared statements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Prepared statements" Watch "Prepared statements" New topic

Prepared statements

Yasir Qureshi

Joined: Apr 26, 2006
Posts: 24
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 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,
Jan Cumps

Joined: Dec 20, 2006
Posts: 2565

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
Yasir Qureshi

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.

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33119


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.

Forum Bartender

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Prepared statements
It's not a secret anymore!