Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes JDBC and Relational Databases and the fly likes Prepared statment executeQuery() error. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Prepared statment executeQuery() error." Watch "Prepared statment executeQuery() error." New topic

Prepared statment executeQuery() error.

Karthik Krishna

Joined: Sep 02, 2008
Posts: 11

I have the following query in a class, and when this class hits the line ps.executeQuery() I get an exception which says " ORA-01006: bind variable does not exist "

I have been trying to work towards different solutions but i do not understand why the ps.executeQuery fails ? does it have anything to do with the nested queries ? Can I have an inline query and the " ps.setString(1, monthYear);ps.setString(2, monthYear);ps.setString(3, monthYear); " can still substitute the values in the inside query ?

Could some one help me out ?

Pass on the knowledge!!
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

I've added code tags to make it more readable.

I only see 3 "?" bind variables in the query. How does the fourth one fit in?

[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
Karthik Krishna

Joined: Sep 02, 2008
Posts: 11
Sorry Jeanne

I am just mimicking a situation which I am encountering and for a few reasons I cannot copy paste the code in here so I am just replicating the issue in here.
You could just comment out the following from line 77 through 80.

# if (!fId.equals("91"))
# {
# ps.setString(4, fId);
# }

And another tiny correction line 38 is missing a bracket.
I agree. Here's the link:
subject: Prepared statment executeQuery() error.
It's not a secret anymore!