Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. import java.sql.*;
  2. import java.util.Random;
  3.  
  4. class MysqlCon{
  5. public static void main(String args[]){
  6. try{
  7. Class.forName("com.mysql.jdbc.Driver");
  8. Connection con=DriverManager.getConnection(
  9. "jdbc:mysql://localhost:3306/SAMPLE24","root","password");
  10. Statement stmt=con.createStatement();
  11. // for (int i = 0; i < 200000; i++) {
  12. // Random rand =new Random(); ;
  13. // int randomNum = rand.nextInt((9999999 - 1000000) + 1) + 1000000;
  14. // stmt.executeUpdate("insert into BORROWER values("+i+","+"'name_"+i+"',"+"'address_"+i+"',"+"'"+randomNum+"');");
  15. // }
  16. // for (int i = 0; i < 200000; i++) {
  17. // Random rand =new Random(); ;
  18. // int randomNum = rand.nextInt((9999999 - 1000000) + 1) + 1000000;
  19. // stmt.executeUpdate("insert into LIBRARY_BRANCH values("+i+","+"'branchName_"+i+"',"+"'address_"+i+"');");
  20. // }
  21.  
  22. for (int i = 0; i < 200000; i++) {
  23. Random rand =new Random(); ;
  24. int randomNum = rand.nextInt((9999999 - 1000000) + 1) + 1000000;
  25. stmt.executeUpdate("insert into BOOK_LOANS values("+i+","+i+","+i+",'"+new Date(0) +"','"+new Date(1) +"');");
  26. }
  27.  
  28. ResultSet rs=stmt.executeQuery("select * from PUBLISHER");
  29. while(rs.next())
  30. System.out.println(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3));
  31. con.close();
  32. }catch(Exception e){ System.out.println(e);}
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement