Advertisement
Guest User

SQL_DataGenerator

a guest
Nov 30th, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package mysql_datagen;
  7.  
  8. /**
  9.  *
  10.  * @author ASROYA
  11.  */
  12. public class MySQL_DataGen {
  13.  
  14.     /**
  15.      * @param args the command line arguments
  16.      */
  17.     public static void main(String[] args) {
  18.        
  19.         double battingAvg = 0.000;  //between 0 and 1 (decimals)
  20.         Integer rbi = 0;    //between 0 and 190
  21.         double era = 0.00;  //between 0 and 10 (decimals)
  22.         Integer wins = 0;       //between 1 and 120
  23.         Integer homeruns = 0;   //between 1 and 75
  24.         Integer player_id = 0;  //between 1 and 400
  25.         Integer season_id = 0;  //between 1 and 15
  26.        
  27.         for (int id = 1001; id <= 1010; id++){
  28.            
  29.             battingAvg = (double) (Math.random() * 0.999 + 0.000);
  30.             rbi = (int) (Math.random() * 190 + 0);
  31.             era = (double) (Math.random() * 10.00 + 0.00);
  32.             wins = (int) (Math.random() * 120 + 1);
  33.             homeruns = (int) (Math.random() * 75 + 1);
  34.             player_id = (int)(Math.random() * 400 + 1);
  35.             season_id = (int) (Math.random() * 15 + 1);
  36.            
  37.             System.out.print("insert into stat (stat_id, batting_average, rbi, era, wins, homeruns, player_id, season_id) ");
  38.             System.out.println("values (" + id +", " + battingAvg + ", " + rbi + ", " + era + ", " + wins + ", " + homeruns + ", " + player_id + ", " + season_id + ");");
  39.         }
  40.     }
  41.    
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement