package JDBC.WildCat.com;

import java.sql.*;
public class TestBatch {

	/**
	 * 批处理添加练习
	 * @param args
	 */
	public static void main(String[] args)throws Exception {
		// step1. new一个Driver
		Class.forName("com.mysql.jdbc.Driver");
		//step2. 拿到一个连接
		String url = "jdbc:mysql://localhost/wild_java?user=root&password=family";
		Connection conn = DriverManager.getConnection(url);
		//step3.创建一个Statement
		Statement stmt=conn.createStatement();
			
		stmt.addBatch("INSERT INTO student5(id,NAME,email) VALUES(23,'周星驰','sdefa@qq.com');");
		stmt.addBatch("INSERT INTO student5(id,NAME,email) VALUES(24,'李连杰','sdef2@qq.com');");
		stmt.addBatch("INSERT INTO student5(id,NAME,email) VALUES(25,'成龙','sd4ea@qq.com');");
		stmt.executeBatch();
		stmt.close();
		conn.close();
	}

}

相关文章:

  • 2021-07-12
  • 2022-12-23
  • 2021-06-27
  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
  • 2021-09-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-08-08
  • 2021-10-26
  • 2022-12-23
  • 2022-02-20
相关资源
相似解决方案