Guest User

Untitled

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