当前位置:   article > 正文

mysql 批处理addBatch用法_mysqlcppconn addbatch

mysqlcppconn addbatch
批处理demo
  1. Connection conn = C3P0Util.getConnection();
  2. PreparedStatement ps = null;
  3. String sql = "insert into t_user values(null,?)";//定义sql的格式
  4. ps = conn.prepareStatement(sql);
  5. for (int i = 0; i < 10000; i++) {
  6. ps.setString(1, "user" + i);
  7. ps.addBatch(); //将sql语句保存起来,先不执行
  8. }
  9. ps.executeBatch();//执行批处理中所有的sql语句
  10. ps.clearBatch();//清空批处理

 

 

查看mysql连接数与客户端ip

SELECT substring_index(host, ':',1) AS host_name,state,count(*) FROM information_schema.processlist GROUP BY state,host_name; 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AI算法诗人/article/detail/61817
推荐阅读
相关标签
  

闽ICP备14008679号