package com.machuang.jdbc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class Demo14 { public static void main(String[] args) { Connection conn = null; Statement st = null; try { Class.forName("com.mysql.jdbc.Driver"); // 建立连接 conn = DriverManager.getConnection( "jdbc:mysql://localhost:3306/testjdbc", "root", "333666"); conn.setAutoCommit(false); // 设置手动递交 st = conn.createStatement(); for (int i = 0; i < 2000; i++) { st.addBatch("insert into t_usr (usrName, pwd, regTime) value ('Cappuccino"+i+"', '64648', now())"); } st.executeBatch(); conn.commit(); //递交 } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if(null != st) { st.close(); } } catch (SQLException e) { e.printStackTrace(); } try { if(null != conn) { conn.close(); } } catch (SQLException e) { e.printStackTrace(); } } } }
如对本文有疑问, 点击进行留言回复!!
[杭电多校2020]第一场 1004 Distinct Sub-palindromes
Swift -- 将本地生成的UIImage进行持久化保存(存到文件中fileManager.createFile)
网友评论