Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1450
  • Last Modified:

How to convert a string to a blob for insertion to DB2

Hi Experts,

I need to update a db2 blob field using a string that I have in memory.  I created a COM.ibm.db2.app.Blob variable and also a java.sql.Blob.  Neither have the setBytes() method that I've read could be used to do this.  Is there anything else I can use?

Thanks for your help.
0
WSADDev
Asked:
WSADDev
1 Solution
 
CEHJCommented:
Try using a PreparedStatement


ps.setBytes(1, yourString.toByteArray());
0
 
WSADDevAuthor Commented:
Good suggestion, but I do not want to use a ps since I'm using Hibernate.  I found that you can very easily do Hibernate.createBlob( myString.getBytes()); which is very handy!

Thanks for your suggestion!
0
 
CEHJCommented:
>>but I do not want to use a ps since I'm using Hibernate

What about

http://www.hibernate.org/73.html

?
0
 
objectsCommented:
> http://www.hibernate.org/73.html

that uses what WSADDev is already using.
0
 
CetusMODCommented:
PAQed with points refunded (125)

CetusMOD
Community Support Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now