Solved

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

Posted on 2006-07-05
6
1,397 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 96
going to wrong jsp page 2 69
Java array 21 150
JVM error from eclipse 1 26
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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 learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses

739 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