Chinaunix首页 | 论坛 | 博客
  • 博客访问: 264696
  • 博文数量: 757
  • 博客积分: 40040
  • 博客等级: 大将
  • 技术积分: 4935
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-09 12:37
文章分类

全部博文(757)

文章存档

2011年(1)

2008年(756)

我的朋友

分类:

2008-09-09 12:40:44

     public void setData() {

      conn = new Conn();

      try {

       String sqlfrom = "select  p.id,p.content from table p  order by p.id   ";

       String sqlinsert = "insert into table   values(?,?)";

       con = conn.getConn("2");

       stmt = con.createStatement(); //从mysql取出大字段

       rs = stmt.executeQuery(sqlfrom);

       con = conn.getConn("1");

       PreparedStatement pstmt = con.prepareStatement(sqlinsert); //向oracle中插入大字段

       int i = 0;

       while (rs.next()) {

       pstmt.setInt(1, rs.getInt(1));

       pstmt.setClob(2, oracle.sql.CLOB.empty_lob());

       pstmt.executeUpdate();  //插入时将大字段设为空

       this.updateOne(con,rs.getInt(1),rs.getString(2));  // 这里调用然后更新这个大字段

       }

 

       rs.close();  //关闭相关连接

       pstmt.close();

       stmt.close();

       con.close();

      } catch (Exception e) {

       e.printStackTrace();

       try

       {

       con.rollback();

       } catch (Exception e1) {

        system.out.println("回滚出现异常!");

        e1.printStackTrace();

       }

      }

     }
    3:该方法实现对应大字段记录的更新


--------------------next---------------------

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