Solved

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

Posted on 2006-07-05
6
1,373 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Eclipse Neon and jdk 1.8.0 11 138
GUI builder for Eclipse? 8 27
servlet requestdispatcher include and forward differences 1 24
servlet  URL Rewriting 1 27
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

920 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

16 Experts available now in Live!

Get 1:1 Help Now