Guest User

Untitled

a guest
Nov 17th, 2016
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. package chessleague;
  2.  
  3. import java.io.IOException;
  4. import java.sql.Connection;
  5. import java.sql.DriverManager;
  6. import java.sql.SQLException;
  7. import java.sql.Statement;
  8. import java.util.Scanner;
  9.  
  10. public class avgFIDErating {
  11. public static void main(String[] args) throws SQLException, IOException {
  12.  
  13. //Connecting to database
  14.  
  15. String user, password, localhost, database;
  16. Scanner sc = new Scanner(System.in);
  17. System.out.println("Type userid, password, hostname and database: ");
  18.  
  19. user = sc.next();
  20. password = sc.next();
  21. localhost = sc.next();
  22. database = sc.next();
  23.  
  24. System.out.println(user+" "+password+" "+localhost);
  25. Connection con = DriverManager.getConnection("jdbc:mysql://"+localhost+":3306/"+database, user, password);
  26. Statement stmnt = con.createStatement();
  27.  
  28. String createProcedure = "create procedure if not exists AvgFIDERating() begin SELECT FIDETitle, AVG(FIDERating) FROM player GROUP BY FIDETitle; end;";
  29. stmnt.executeUpdate(createProcedure);
  30. System.out.println("Procedure created");
  31. con.close();
  32. }
  33. }
Add Comment
Please, Sign In to add comment