• 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
Marshal
Posts: 35272
383
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic