zoukankan      html  css  js  c++  java
  • 8.24 批处理

    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    
    import com.gem.demo.util.JDBCUtil;
    
    /**
     *
     * Title: Demo02
     *
     * Description: 
     * 批处理
     * @version v0.01
     *
     * @author ByChai
     *
     * @date 2020年8月24日 下午1:35:36
     *
     *
     */
    public class Demo02 {
        public static void main(String[] args) {
            Connection conn=null;
            PreparedStatement psmt=null;
            //
            long start=System.currentTimeMillis();
            try {
                //jdbc
                conn=JDBCUtil.getConnection();
                String  sql="insert into account (username,pwd,balance) values(?,?,?)";
                //
                psmt=conn.prepareStatement(sql);
                for(int i=10;i<50000; i++) {
                    psmt.setString(1, i+"");//设置账号
                    psmt.setString(2,"123456");//密码
                    psmt.setDouble(3, 1000);//余额
                    psmt.addBatch();//加入批处理
                    if(i%1000==0) {//1000  2000   49000 49999
                        psmt.executeBatch();//执行批处理
                        psmt.clearBatch();
                    }
                }
                psmt.executeBatch();
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }finally {
                JDBCUtil.close(psmt, conn);
            }
            long end=System.currentTimeMillis();
            System.out.println("批处理时间为:"+(end-start)/1000+"秒");
        }    
            
    }

    批处理

  • 相关阅读:
    github的使用
    QPalette的用法
    QTimer的用法
    QStatusBar的用法
    QWhatsThis的用法
    QString::​arg的用法
    qt中ui的 使用介绍
    安全协议IPSEC
    安全协议ssl
    对称加密和非对称加密
  • 原文地址:https://www.cnblogs.com/Guang09/p/13553905.html
Copyright © 2011-2022 走看看