• java读取Oracle中大字段数据(CLOB)的方法


    2.Oracle数据库中有一个字段是CLOB类型,使用java 解析.

    1.使用java解析clob类型内容

     public String clobToString(Clob c) {
            StringBuffer sb = new StringBuffer(1024);
            Reader instream = null;
            try {
                instream = c.getCharacterStream();
                char[] buffer = new char[(int) c.length()];
                int length = 0;
                while ((length = instream.read(buffer)) != -1) {
                    sb.append(buffer, 0, length); 
                }
            } catch (Exception ex) {
                ex.printStackTrace();
                return null;
            } finally {
                try {
                    if (instream != null)
                        instream.close();
                } catch (Exception dx) {
                    instream = null;
                }
            }
            return sb.toString();
        }
    if(pageObject.getResultList() != null && pageObject.getResultList().size() > 0){
               for(int i=0,j=pageObject.getResultList().size(); i < j;i++){
                   Map<String,Object> maps = (Map<String, Object>) pageObject.getResultList().get(i);
                   maps.put("DISPATCHINGRULESNAME",this.clobToString((Clob) maps.get("DISPATCHINGRULESNAME"))); //这里将Clob类型转化成字符串,调用clobToString((Clob)方法
               }
            }
    相关链接:
       https://blog.csdn.net/u011342403/article/details/72904827
      https://blog.csdn.net/u010670151/article/details/52210333
    2.使用oracle函数 to_char(字段)
    select to_char(t.billName) as billName from T_CC_SHARE_DISPATCH_RULE t 


  • 相关阅读:
    Python类知识点
    安装psycopg2时出错:Error: pg_config executable not found.
    top命令
    Ubuntu18.10创建软件图标
    初始化Redis密码
    Ubuntu修改root密码,ssh 允许root用户登录
    Flask_Migrate数据库迁移
    Ubuntu18.04 systemd开机自启
    dnspython
    记一次Celery的仇
  • 原文地址:https://www.cnblogs.com/Steven5007/p/11245379.html
Copyright © 2020-2023  润新知