Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4141725
  • 博文数量: 447
  • 博客积分: 1241
  • 博客等级: 中尉
  • 技术积分: 5786
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-27 06:48
个人简介

读好书,交益友

文章分类

全部博文(447)

文章存档

2023年(6)

2022年(29)

2021年(49)

2020年(16)

2019年(15)

2018年(23)

2017年(67)

2016年(42)

2015年(51)

2014年(57)

2013年(52)

2012年(35)

2011年(5)

分类: Java

2015-01-29 17:32:10

最近要去客户那里安装程序,使用客户的oracle集群,省掉了很多麻烦。

但是也出现了不少问题。

有几个 页面无法显示,频繁出现

java.lang.ClassCastException: $Proxy112 cannot be cast to java.lang.String

经过确认是wm_concat引发的麻烦。


用户的版本

SQL>  select * from v$version;

BANNER
--------------------------------------------------------------------------------

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE    11.2.0.3.0      Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production

SQL> desc wmsys.wm_concat;
FUNCTION wmsys.wm_concat RETURNS CLOB
参数名称                       类型                    输入/输出默认值?
------------------------------ ----------------------- ------ --------
 P1                             VARCHAR2                IN 


我们的数据库


SQL>  select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

SQL> desc wmsys.wm_concat;
FUNCTION wmsys.wm_concat RETURNS VARCHAR2
 Argument Name   Type   In/Out Default?
 ------------------------------ ----------------------- ------ --------
 P1    VARCHAR2  IN

返回类型不一致。

处理其实也简单,使用to_char(wm_concat(G.ip_id))

或者做一下兼容性处理

添加处理函数


/**
     * 将CLOB转成String ,静态方法
     * @param clob 字段
     * @return 内容字串,如果出现错误,返回null
     */
    public final static String clob2String(Clob clob){
      if (clob == null){
        return null;
      }
      StringBuffer sb = new StringBuffer(65535);//64K
      Reader clobStream = null;//创建一个输入流对象
      try{
        clobStream = clob.getCharacterStream();
        char[] b = new char[60000];//每次获取60K
        int i = 0;
        while((i = clobStream.read(b)) != -1){
          sb.append(b,0,i);
        }
      }
      catch(Exception ex){
        sb = null;
      }
      finally{
        try{
          if (clobStream != null)
            clobStream.close();
        }
        catch (Exception e) {
        }
      }
      if (sb == null)
        return null;
      else
        return sb.toString();
    }

添加兼容性处理

 if (tem[10] instanceof java.sql.Clob) {
      task.setListName(QueryUtil
        .clob2String((java.sql.Clob) tem[10]));
     } else {
      task.setListName((String) tem[10]);
     }

阅读(3067) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~