Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- import java.util.Random;
- class MysqlCon{
- public static void main(String args[]){
- try{
- Class.forName("com.mysql.jdbc.Driver");
- Connection con=DriverManager.getConnection(
- "jdbc:mysql://localhost:3306/SAMPLE24","root","password");
- Statement stmt=con.createStatement();
- // for (int i = 0; i < 200000; i++) {
- // Random rand =new Random(); ;
- // int randomNum = rand.nextInt((9999999 - 1000000) + 1) + 1000000;
- // stmt.executeUpdate("insert into BORROWER values("+i+","+"'name_"+i+"',"+"'address_"+i+"',"+"'"+randomNum+"');");
- // }
- // for (int i = 0; i < 200000; i++) {
- // Random rand =new Random(); ;
- // int randomNum = rand.nextInt((9999999 - 1000000) + 1) + 1000000;
- // stmt.executeUpdate("insert into LIBRARY_BRANCH values("+i+","+"'branchName_"+i+"',"+"'address_"+i+"');");
- // }
- for (int i = 0; i < 200000; i++) {
- Random rand =new Random(); ;
- int randomNum = rand.nextInt((9999999 - 1000000) + 1) + 1000000;
- stmt.executeUpdate("insert into BOOK_LOANS values("+i+","+i+","+i+",'"+new Date(0) +"','"+new Date(1) +"');");
- }
- ResultSet rs=stmt.executeQuery("select * from PUBLISHER");
- while(rs.next())
- System.out.println(rs.getString(1)+" "+rs.getString(2)+" "+rs.getString(3));
- con.close();
- }catch(Exception e){ System.out.println(e);}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement