读取Clob另一方法

来源:互联网 发布:unity3d 免费版 区别 编辑:程序博客网 时间:2024/05/11 03:58
最近需要读取数据库中的Clob字段,查看网上的资料没有列出以下方法,现给于补充。
      Clob clob1 = (Clob) rset.getClob("ask_detail");
        if(clob1 != null){
          BufferedReader in1 = new BufferedReader(clob1.getCharacterStream());
          StringWriter out1 = new StringWriter();
          int c;
          while ( (c = in1.read()) != -1) {
            out1.write(c);
          }
          String askDetail = out1.toString();

          customAskInfo.setAskDetail(askDetail);

        }else if(clob1==null){
           customAskInfo.setAskDetail("");
        }


       不过该方法是逐个读取字符串,可能效率比较低,感兴趣的朋友可以测试一下