addBatch(String sql)
引數說明:public void bathInsert(){ Connection conn=getCon(); //省略部分程式碼 String sql1="insert into tb_users(name)values('aaa')"; //新增資料 String sql2="insert into tb_users(name)values('bbb')"; String sql3="insert into tb_users(name)values('ccc')"; Statement stmt; try{ stmt=conn.createStatement(); //獲取Statement物件 stmt.addBatch(sql1); //新增sql語句 stmt.addBatch(sql2); stmt.addBatch(sql3); stmt.executeBatch(); //批次執行 stmt.close(); }catch(SQLException e){ e.printStackTrace(); } }