Solved

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

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Should localization be done inside spring controller 5 36
jdbc error in jsp application 20 71
Desingning Refactoring existing code 2 31
Is there a simpler dropbox system? 10 44
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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 will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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.

713 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