The moose likes JDBC and the fly likes set/getBytes not working well with Oracle 8 BLOB, please help Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "set/getBytes not working well with Oracle 8 BLOB, please help" Watch "set/getBytes not working well with Oracle 8 BLOB, please help" New topic
Author

set/getBytes not working well with Oracle 8 BLOB, please help

Yuriy Zilbergleyt
Ranch Hand

Joined: Dec 13, 2004
Posts: 429
Hello,

I am trying to store a byte array in an BLOB column. I set it with PreparedStatement.setBytes() and retrieve with ResultSet.getBytes(), and what I put in look nothing like what comes out, even using a simple {0,1,2,3} array for testing. I wrote similar code a few months ago to store serialized Java objects in a MySQL database, and it worked perfectly. Does Oracle do things differently? Is there any other way to store serialized Java objects in an Oracle 8 database? JDO is not an option at this point.

Thank you in advance,
Yuriy Zilbergleyt
Yuriy Zilbergleyt
Ranch Hand

Joined: Dec 13, 2004
Posts: 429
Hmm, it seems ResultSet.getBinaryInputStream() returns the correct bytes, so I can use it instead of getBytes(). I'm still curious as to why getBytes() doesn't work.

Yuriy
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26177
    
  66

I've used getBytes() successfully with Oracle. Are you using the classes12.zip driver or a different one?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Yuriy Zilbergleyt
Ranch Hand

Joined: Dec 13, 2004
Posts: 429
I'm using ojdbc14.jar. When you used getBytes, was it on a BLOB or some other column type?

Yuriy
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: set/getBytes not working well with Oracle 8 BLOB, please help
 
Similar Threads
Store array in database
Image Databases
Image insertion into database through JPA
inserting images into an oracle database
Storing Object of a class in Sybase