Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. package main_pack;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6. import java.sql.SQLException;
  7. import java.sql.Statement;
  8. import java.util.Scanner;
  9. import java.util.concurrent.ThreadLocalRandom;
  10.  
  11. public class launcher {
  12. Connection conn;
  13. Statement st;
  14. String sentence;
  15. ResultSet rs;
  16.  
  17. String ip, port, user, pass;
  18.  
  19. public launcher(String ip, String port, String u, String pw) {
  20. this.ip = ip;
  21. this.port = port;
  22. this.user = u;
  23. this.pass = pw;
  24.  
  25. try {
  26. conn = DriverManager.getConnection(
  27. "jdbc:mysql://"+ this.ip + ":" + this.port + "",
  28. this.user, this.pass);
  29. conn.setAutoCommit(true);
  30. st = conn.createStatement();
  31. System.out.print("OK, Connected with " + this.user);
  32. } catch (SQLException e) {
  33. e.printStackTrace();
  34. }
  35.  
  36. }
  37.  
  38. public static void main(String[] args) {
  39. String add, p, usr, pw;
  40. Scanner sc = new Scanner(System.in);
  41. System.out.println("Escribir IP: ");
  42. add = sc.nextLine();
  43. System.out.println("Escribir PORT: ");
  44. p = sc.nextLine();
  45. System.out.println("Escribir USER: ");
  46. usr = sc.nextLine();
  47. System.out.println("Escribir PASSWORD: ");
  48. pw = sc.nextLine();
  49. launcher data = new launcher(add, p, usr, pw);
  50. //launcher data = new launcher("192.168.56.11", "3306", "dummy", "foobar2020");
  51.  
  52. int x = ThreadLocalRandom.current().nextInt(0, 11);
  53. System.out.print(x);
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement