Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.sql.SQLException: ORA-01006: bind variable does not exist

 
Carissa Lew
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am learning JDBC. I copied an example from a web site, but when I ran it, I got the error java.sql.SQLException: ORA-01006: bind variable does not exist.
After looking at the code myself, I noticed that the line "ResultSet rs = stmt.executeQuery(sql);" is causing the problem. But I cannot tell what is wrong with this statement.


Here is the code.

 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eva,

Welcome to JavaRanch!

The problem comes when you reuse your prepared statement as an ordinary statement. You should close stmt, and then create a new statement with Connection.createStatement() to execute your static SQL.
 
Carissa Lew
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I took your suggestion and it's working now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic