Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.sql.SQLException: not all varaibles bound

 
Rudra Nath
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did following in JAVA:

String query = "update mytable set image=? where column1= \'" +columnvalue+"\'";
PreparedStatement st1=conn.prepareStatement(query);
st1.setBinaryStream(1,new FileInputStream(myImg),(int)myImg.length());
st1.executeUpdate();

where myImg contains full path with filename where an image is stored.

But I am getting follwoing error:
java.sql.SQLException: not all varaibles bound.

What to do?
 
Winston Gutkowski
Bartender
Pie
Posts: 10427
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rudra Nath wrote:But I am getting follwoing error:
java.sql.SQLException: not all varaibles bound.

It would be useful if you supply the exact error (ie, the first few lines of the stacktrace), along with an indication of precisely which line is throwing it.

However, that said, your statement looks very odd. Specifically, I'm not at all sure that you can set a BLOB with a simple '=' assignment (but I may be wrong).

Winston
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, you should be using a PS parameter for your columnvalue as well:

 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What database and JDBC driver are you using? Sometimes approaches that work with one database/driver might fail with another.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin Vajsar wrote:What database and JDBC driver are you using? Sometimes approaches that work with one database/driver might fail with another.


yes blobs are vendor specific.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic