aspose file tools*
The moose likes JDBC and the fly likes java.sql.SQLException: not all varaibles bound Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.SQLException: not all varaibles bound" Watch "java.sql.SQLException: not all varaibles bound" New topic
Author

java.sql.SQLException: not all varaibles bound

Rudra Nath
Greenhorn

Joined: May 12, 2012
Posts: 9
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

Joined: Mar 17, 2011
Posts: 8427
    
  23

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


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Also, you should be using a PS parameter for your columnvalue as well:

Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3611
    
  60

What database and JDBC driver are you using? Sometimes approaches that work with one database/driver might fail with another.
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.sql.SQLException: not all varaibles bound