JDBC 操作插入表出现javax.sql.rowset.serial.SerialBlob cannot be cast to oracle.sql.BLOB

/**
     * 接口方法
     */
    public void excuteInputDB(SynchServiceConfig synchServiceConfig)
            throws Exception {
        try {
//          if(!"".equals(queryQdParaWayinfo()))
//          {
//              CLOB clob = oracle.sql.CLOB.createTemporary(oraConn, false, oracle.sql.CLOB.DURATION_SESSION);
//              clob.putString(1, queryQdParaWayinfo());
//             
//              insertMyAnnouncement(VALID_WAYINFO_SENDER, curTime, VALID_WAYINFO_TITTLE, clob);//渠道资料缺失提醒推送
//          }
          if(!"".equals(queryQdSysNetpointuser())){
              //将String类型转oracle.sql.CLOB类型插入到数据库
              CLOB cb = oracle.sql.CLOB.createTemporary(oraConn, false, oracle.sql.CLOB.DURATION_SESSION);
              cb.putString(1, queryQdSysNetpointuser());
             insertQdSysNetpointuser(VALID_WAYINFO_SENDER, curTime, VALID_EMPLOYEE_TITTLE, cb);//营业员资料缺失提醒推送
          }
          System.out.println("===测试模块END==");
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 获取缺失的渠道资料的数据
     * @throws SQLException 
     */
    private String queryQdParaWayinfo() throws SQLException {

        /**
         * way.id-- id vc_wayacctname-- 渠道经理联系人 way.c_wayid-- 网点编号 vc_acctname--
         * 银行帐户名 vc_acctbank-- 开户银行 vc_wayacctno-- 银行帐号 dept_sx1-- 渠道属性
         * c_accttype-- 帐户类型 si_chain-- 店铺属性 c_type-- 连锁属性 dept_sx3-- 星级
         * way.manager_name--渠道经理
         */
        String msg = "";
        String msgs = "";
        
        PreparedStatement ps = null;
        ResultSet rs = null;
        
        String sql = "select way.id, "
                + " NVL(way.vc_wayacctname, ' ') AS vc_wayacctname, "
                + " NVL(way.c_wayid, ' ') AS c_wayid, "
                + " NVL(way.vc_acctname, ' ') AS vc_acctname, "
                + " NVL(way.vc_acctbank, ' ') AS vc_acctbank, "
                + " NVL(way.vc_wayacctno, ' ') AS vc_wayacctno, "
                + " NVL(way.dept_sx1, ' ') AS dept_sx1, "
                + " NVL(way.c_accttype, ' ') AS c_accttype,"
                + " NVL(way.si_chain, -9) AS si_chain, "
                + " NVL(way.c_type, ' ') AS c_type, "
                + " NVL(way.dept_sx3, ' ') AS dept_sx3, "
                + " NVL(way.manager_name, ' ') AS manager_name "
                + " from qd_para_wayinfo way where regexp_like(way.c_wayid,'QD[0-9]{6}') and way.si_waystate = 1 ";
        System.out.println("sql......"+sql);
        try {
            ps = oraConn.prepareStatement(sql);
            rs = ps.executeQuery();
            
            while (rs.next()) {
                
                if ("".equals(rs.getString("vc_acctname").trim())) {
                    msg = msg + "银行帐户名为空,";
                }
                if ("".equals(rs.getString("vc_acctbank").trim())) {
                    msg = msg + "开户银行为空,";
                }
                if ("".equals(rs.getString("vc_wayacctno").trim())) {
                    msg = msg + "银行帐号为空,";
                }
                if ("".equals(rs.getString("dept_sx1").trim())) {
                    msg = msg + "渠道属性为空,";
                }
                if ("".equals(rs.getString("c_accttype").trim())) {
                    msg = msg + "帐户类型为空,";
                }
                if (rs.getInt("si_chain") == -9) {
                    msg = msg + "店铺属性为空,";
                }
                if (rs.getInt("si_chain") == 3
                        && "".equals(rs.getString("c_type").trim())) {
                    msg = msg + "连锁属性为空,";
                }if("".equals(rs.getString("c_wayid").trim())) {
                    msg = msg + "渠道编号为空";
                }
                if ("".equals(rs.getString("dept_sx3").trim())) {
                    msg = msg + "星级为空";
                }

                if (!"".equals(msg)) {
                    
                    msgs = msgs + rs.getString("manager_name") + "|"
                            + rs.getString("c_wayid") + "|" + msg+"|";
                    
                }
                msg = "";
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally{
            if(rs !=null){rs.close();}
            if(ps !=null){ps.close();}
        }
        
        return msgs;
    }
    /**
     * 插入公告表 qd_anno_myAnnouncement
     * @throws SQLException 
     * */
    private boolean insertMyAnnouncement(long sender,Date send_time,String title,Clob cb) throws SQLException{
        
        
        boolean flag = false;
        PreparedStatement psInsert = null;
        
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        
        try {
            String sql =
                "insert into qd_anno_myannouncement(id, sender , send_time , title , content ) " +
                "select qd_anno_myannouncement_seq.nextval,? , ? , ? ,?  from dual ";
            psInsert = oraConn.prepareStatement(sql);
            psInsert.setLong(1, sender);
            
            psInsert.setTimestamp(2, Timestamp.valueOf(sf.format(send_time)));
    
            psInsert.setString(3, title);
            
            psInsert.setClob(4, cb);
            
            int num  = psInsert.executeUpdate();
            
            if(num > 0){
                flag = true;
                
            }
            oraConn.commit();
        } catch (Exception e) {
            e.printStackTrace();
            oraConn.rollback();
        }finally{
              if(psInsert !=null){psInsert.close();}    
        }
    
        return flag;
    }

 

posted @ 2015-09-16 18:28  阿若蜜意  阅读(6008)  评论(0编辑  收藏  举报