aspose file tools
The moose likes JDBC and Relational Databases and the fly likes JDBC-ODBC Blob insert error using prepared statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JDBC-ODBC Blob insert error using prepared statement" Watch "JDBC-ODBC Blob insert error using prepared statement" New topic
Author

JDBC-ODBC Blob insert error using prepared statement

Graeme Mooney
Greenhorn

Joined: Apr 20, 2012
Posts: 2
Hi,

I am having issues storing a blob. My code is as follows:



When I run this I get the following error:

Exception in thread "main" java.lang.UnsupportedOperationException
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setBlob(Unknown Source)

It looks like it is looking for the wrong Prepared Statement as the error shows JdbcOdbcPreparedStatement when I want java.sql.PreparedStatement

Any help would be much appreciated.

Thanks,
Graeme
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

there have been quite a few threads on here recently about clobs, have you read them, as it isn't as easy as just typing set blob.
I am sure the theory is the same for both.
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

And welcome to the Ranch, hope you like it here and stay around
Graeme Mooney
Greenhorn

Joined: Apr 20, 2012
Posts: 2
Thanks for the replies guys.

I have opted to use the setBinaryStream instead of the setBlob



This worked a charm.

I tried the setBlob method with a regular JDBC connectino and not JDBC-ODBC connection bridge and it worked ok. Unfortunatly i have to use the JDBC-ODBC connection bridge for what i am working on. If I find out why one works and the other doesnt i will post here.

Thanks,
Graeme
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3717
    
  61

The JDBC-ODBC bridge is quite old and not much supported. It seems that the setBlob method was not actually implemented in that driver.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JDBC-ODBC Blob insert error using prepared statement
 
It's not a secret anymore!