Most efficient solution for reading CLOB to String, and String to CLOB in Java?

前端 未结 11 1299
长发绾君心
长发绾君心 2020-12-01 07:04

I have a big CLOB (more than 32kB) that I want to read to a String, using StringBuilder. How do I do this in the most efficient way? I can not use the \"int length\" constru

11条回答
  •  旧时难觅i
    2020-12-01 08:07

    I can not use the "int length" constructor for StringBuilder since the length of my CLOB is longer than a int and needs a long value.

    If the CLOB length is greater than fits in an int, the CLOB data won't fit in a String either. You'll have to use a streaming approach to deal with this much XML data.

    If the actual length of the CLOB is smaller than Integer.MAX_VALUE, just force the long to int by putting (int) in front of it.

提交回复
热议问题