• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Sheriff
Posts: 36027
431
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've used getBytes() successfully with Oracle. Are you using the classes12.zip driver or a different one?
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using ojdbc14.jar. When you used getBytes, was it on a BLOB or some other column type?

Yuriy
 
I found a beautiful pie. And a tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!