Advertisement
Guest User

Untitled

a guest
Feb 17th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. package generateSamepleDataSet;
  2.  
  3. import java.sql.*;
  4.  
  5. /**
  6. * Created by jkyju_000 on 2/16/2016.
  7. */
  8. public class GenerateProcessSqlDatabase {
  9. public static void main(String args[]) {
  10. Connection c = null;
  11. Statement stmt = null;
  12. try {
  13. Class.forName("org.postgresql.Driver");
  14. c = DriverManager
  15. .getConnection("jdbc:postgresql://localhost:5432/postgres",
  16. "postgres", "adfadf12");
  17. c.setAutoCommit(false);
  18. System.out.println("Opened database successfully");
  19.  
  20. stmt = c.createStatement();
  21.  
  22. for (int i = 0; i < 45000; i++) {
  23. String sql = "INSERT INTO ARRIVALS (DATEY,DATEM,DATED,TIMEHST,TIMEMST,TIMEHED,TIMEMED) "
  24. + "VALUES ( " + (2012 + (int)(Math.random() * ((2015 - 2012) + 1))) + ", " + (1 + (int)(Math.random() * ((12 - 1) + 1))) + ", " + (1 + (int)(Math.random() * ((30 - 1) + 1))) + ", " + (7 + (int)(Math.random() * ((19 - 1) + 1))) + ", " + (0 + (int)(Math.random() * ((59 - 0) + 1))) + ", "I have no idea what to put in TIMEHED", "Also have no idea what to put in TIMEMED" );";
  25. stmt.executeUpdate(sql);
  26. }
  27.  
  28. stmt.close();
  29. c.commit();
  30. c.close();
  31. } catch (Exception e) {
  32. System.err.println( e.getClass().getName()+": "+ e.getMessage() );
  33. System.exit(0);
  34. }
  35. System.out.println("Records created successfully");
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement