This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JDBC 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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
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: 3610
    
  60

The JDBC-ODBC bridge is quite old and not much supported. It seems that the setBlob method was not actually implemented in that driver.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC-ODBC Blob insert error using prepared statement