Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package generateSamepleDataSet;
- import java.sql.*;
- /**
- * Created by jkyju_000 on 2/16/2016.
- */
- public class GenerateProcessSqlDatabase {
- public static void main(String args[]) {
- Connection c = null;
- Statement stmt = null;
- try {
- Class.forName("org.postgresql.Driver");
- c = DriverManager
- .getConnection("jdbc:postgresql://localhost:5432/postgres",
- "postgres", "adfadf12");
- c.setAutoCommit(false);
- System.out.println("Opened database successfully");
- stmt = c.createStatement();
- for (int i = 0; i < 45000; i++) {
- String sql = "INSERT INTO ARRIVALS (DATEY,DATEM,DATED,TIMEHST,TIMEMST,TIMEHED,TIMEMED) "
- + "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" );";
- stmt.executeUpdate(sql);
- }
- stmt.close();
- c.commit();
- c.close();
- } catch (Exception e) {
- System.err.println( e.getClass().getName()+": "+ e.getMessage() );
- System.exit(0);
- }
- System.out.println("Records created successfully");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement