使用INSERT INTO table(fieldname,fieldname2,...) select fieldname,fieldname2,... from table 2 where ...可以将100条记录一次插入表中

解决方案 »

  1.   

    不行啊,我的table 2在另一个主机的另一个数据库中
      

  2.   

    JDBC 2.0不是支持成批更新吗?
    conn.setAutoCommit(false);
    stmt = conn.createStatement();
    stmt.addBatch("insert into ...");
    stmt.addBatch("insert into ...");
    ...
    stmt.executeBatch();
    conn.commit();
    conn.setAutoCommit(true);
      

  3.   

    可以:
    public ResultSet executeQuery(String sql) 
         {rs = null;
          try
            { rs.begin();//事务处理
                while(..)
           rs = stmt.executeQuery(sql);
              rs.commit(); 
            }
          catch(SQLException ex) 
            {
             rs.rollback();   
              System.err.println("aq.executeQuery:"+ex.getMessage());
            }
          return rs;
         }
    注意:1。update data时要加事务处理
       2。象楼上说的,优化SQL
      

  4.   

    不行啊,我的table 2是在另一台主机的另一个数据库中
      

  5.   

    哈哈------
    有意思。
    1,你自己做一个连接池
    2,like this :rs = stmt.executeQuery(sql,“host ip”,"database name");
    3,注意,如果网断了,你的连接池如何处理
      

  6.   

    当时俺被逼的没有办法了,只好用SQL中的union来把一片查询语句连起来,批处理不能用于查询,事务好像也是一条一条的提交,结果还不是在一个ResultSet中,我记得那个玩意好像有个getMoreResultSet方法,但还是不在一个ResultSet中,至于插入删除修改可以用批处理。
      

  7.   

    qiyao(享受每一天),rs.begin(),stmt.executeQuery(sql,“host ip”,"database name")所用的这两个方法我怎么没有在doc里见的过,请指教以下。