Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2004
    Posts
    10

    Unanswered: 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

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: How to convert StringBuffer to Clob type in java

    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().

  3. #3
    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

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    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

  5. #5
    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

  6. #6
    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.

  7. #7
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •