public class TestJDBC {
private static long COUNT = 1000000;
private static long BATCH_SIZE = 20000;
private static long COMMIT_SIZE = 100000;
public static Connection getConnection() {
Connection conn = null;
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/test";
String user = "root";
String password = "root";
try {
// 1 加载驱动程序
Class.forName(driver);
// 2 连接数据库
conn = DriverManager.getConnection(url, user, password);
} catch (ClassNotFoundException e) {
System.out.println("Sorry,can`t find the Driver!");
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return conn;
}
public void insertTest() {
Connection conn = null;
PreparedStatement pstat = null;
String sql = "insert into users values(?,?)