If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How to convert StringBuffer to Clob type in java

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-14-04, 10:31
sangeethk sangeethk is offline
Registered User
 
Join Date: Jan 2004
Posts: 10
How to convert StringBuffer to Clob type in java

Hello,

I'm facing few problems in handling Clob type. I will post one by one with the response I'm getting for my first doubt.

I'm new to Db2 and java. I have no practical idea of handling LOBs

My doubt is,
I'm having a StringBuffer, whose length is comparitively very large say > 1Mb. I want to convert this to a java.sql.Clob type.

The purpose of this convertion i'll post after getting response from any one of you for this doubt.

Please give me a solution for this...

awaiting reply

With regards
sangeeth
Reply With Quote
  #2 (permalink)  
Old 01-14-04, 12:46
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Re: How to convert StringBuffer to Clob type in java

Quote:
Originally posted by sangeethk
Hello,

I'm facing few problems in handling Clob type. I will post one by one with the response I'm getting for my first doubt.

I'm new to Db2 and java. I have no practical idea of handling LOBs

My doubt is,
I'm having a StringBuffer, whose length is comparitively very large say > 1Mb. I want to convert this to a java.sql.Clob type.

The purpose of this convertion i'll post after getting response from any one of you for this doubt.

Please give me a solution for this...

awaiting reply

With regards
sangeeth
I don't believe you can create a Clob object yourself - you can only get it from a ResultSet. To store StingBuffer contents in a CLOB column you should use PreparedStatement.setCharacterStream().
Reply With Quote
  #3 (permalink)  
Old 01-15-04, 08:29
sangeethk sangeethk is offline
Registered User
 
Join Date: Jan 2004
Posts: 10
Smile

Thank u very much n_i for ur response.

Related to that i have posted another doubt can u please give a look at it

subject:java.lang.AbstractMethodError: COM/ibm/db2/jdbc/app/DB2PreparedStatement.setCharacterStream

With regards,
sangeeth
Reply With Quote
  #4 (permalink)  
Old 01-15-04, 09:37
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally posted by sangeethk
Thank u very much n_i for ur response.

Related to that i have posted another doubt can u please give a look at it

subject:java.lang.AbstractMethodError: COM/ibm/db2/jdbc/app/DB2PreparedStatement.setCharacterStream

With regards,
sangeeth
This means the method is not implemented by the driver that you're using. Try other methods, e.g. setAsciiStream() or setUnicodeStream(), depending on what's in your StringBuffer
Reply With Quote
  #5 (permalink)  
Old 01-16-04, 02:11
sangeethk sangeethk is offline
Registered User
 
Join Date: Jan 2004
Posts: 10
Unhappy

Yes it worked with setAsciiStream(), but to do that i modified my code as follows,

1. I wrote the content of StringBuffer to a temporary file.
2. Then, i got the InputStream handle of above file, to send as
parameter to setAsciiStream() of preparedStatement.

Now I'm facing new problem,

that is, only part of the clob is written into the db.I think it is only 4000 bytes.

Regarding this i think, i have to increase the buffer pool size.

I don't know how to do.....

Can u please help me..

I have even posted this doub't to dbforum...

With regards,
sangeeth
Reply With Quote
  #6 (permalink)  
Old 12-30-04, 05:51
mats2004 mats2004 is offline
Registered User
 
Join Date: Dec 2004
Posts: 1
converting stringbuffer obj to a CLOB Object

Hi,

I also needed the same thing you are working on. Can you please let me know after writing the contents of a string object to a temporary file how did you get the handle of the InputStream.?


Your immediate answer would be helpful.

Thanks,

Mathangi.
Reply With Quote
  #7 (permalink)  
Old 01-04-05, 08:58
sangeethk sangeethk is offline
Registered User
 
Join Date: Jan 2004
Posts: 10
Thumbs up Re:converting stringbuffer obj to a CLOB Object

Hi,

This is as simple as follows,

InputStream is= new FileInputStream(tempfilehandle);

regards,
sangeeth
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On