import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class First {
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
PreparedStatement stmt = con.prepareStatement("insert into second values (?,?)");
for(int i=0;i<20;i++){
stmt.setInt(1,i);
stmt.setInt(2,i);
stmt.executeUpdate();
}
con.close();
}
catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class First {
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
PreparedStatement stmt = con.prepareStatement("insert into second values (?,?)");
for(int i=0;i<20;i++){
stmt.setInt(1,i);
stmt.setInt(2,i);
stmt.executeUpdate();
}
con.close();
}
catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
output:-
No comments:
Post a Comment