使用wm_concat函数导致字符串过长

场景:使用select wm_concat(xxxxx) from table 的时候 返回的字符串过长 

解决方案 :使用to_clob 将字符串转成 clob类型,但是由于使用的前端框架不能解析clob类型的值

      再将clob转化成String类型 

      

List<Map> olists=oDao.queryOrgRoleInfo(query);
        for(Map omap :olists ){
            try {
                omap.put("ORGNAME", ClobToString((Clob)omap.get("ORGNAME")));
            } catch (SQLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
 public String ClobToString(Clob clob) throws SQLException, IOException {
          
           String reString = "";
               if (clob == null){
               return "";
               }
            Reader is = clob.getCharacterStream();// 得到流
            BufferedReader br = new BufferedReader(is);
            String s = br.readLine();
            StringBuffer sb = new StringBuffer();
            while (s != null) {// 执行循环将字符串全部取出付值给StringBuffer由StringBuffer转成STRING
             sb.append(s);
             s = br.readLine();
            }
            reString = sb.toString();
            return reString;
          }

猜你喜欢

转载自www.cnblogs.com/LEEEEEASON/p/9285354.html