Solved

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

Posted on 2006-07-05
6
1,368 Views
Last Modified: 2012-05-05
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
Comment
Question by:WSADDev
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 17044276
Try using a PreparedStatement


ps.setBytes(1, yourString.toByteArray());
0
 

Author Comment

by:WSADDev
ID: 17046030
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 17046062
>>but I do not want to use a ps since I'm using Hibernate

What about

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

?
0
 
LVL 92

Expert Comment

by:objects
ID: 17047188
> http://www.hibernate.org/73.html

that uses what WSADDev is already using.
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 17258221
PAQed with points refunded (125)

CetusMOD
Community Support Moderator
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now