//java连接mysql数据库 import java.sql.*; public class Myproject { public static void main(String[] args){ try{ Class.forName("org.gjt.mm.mysql.Driver"); String url="jdbc:mysql://localhost:3306/my"; String username="root"; String password="123456"; Connection con =DriverManager.getConnection(url,username,password); int num=100; PreparedStatement statement =con.prepareStatement("INSERT INTO useers VALUES(?,?)"); for(int i=0;i<num;i++){ statement.setString(1,"bobuke"+1); statement.setString(2,"bo"+1); statement.executeUpdate(); } } catch(Exception e){ System.out.println("An error has occurred:"+e.toString()); e.printStackTrace(); } } }