Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package chessleague;
- import java.io.IOException;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.util.Scanner;
- public class avgFIDErating {
- public static void main(String[] args) throws SQLException, IOException {
- //Connecting to database
- String user, password, localhost, database;
- Scanner sc = new Scanner(System.in);
- System.out.println("Type userid, password, hostname and database: ");
- user = sc.next();
- password = sc.next();
- localhost = sc.next();
- database = sc.next();
- System.out.println(user+" "+password+" "+localhost);
- Connection con = DriverManager.getConnection("jdbc:mysql://"+localhost+":3306/"+database, user, password);
- Statement stmnt = con.createStatement();
- String createProcedure = "create procedure if not exists AvgFIDERating() begin SELECT FIDETitle, AVG(FIDERating) FROM player GROUP BY FIDETitle; end;";
- stmnt.executeUpdate(createProcedure);
- System.out.println("Procedure created");
- con.close();
- }
- }
Add Comment
Please, Sign In to add comment