Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main_pack;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.util.Scanner;
- import java.util.concurrent.ThreadLocalRandom;
- public class launcher {
- Connection conn;
- Statement st;
- String sentence;
- ResultSet rs;
- String ip, port, user, pass;
- public launcher(String ip, String port, String u, String pw) {
- this.ip = ip;
- this.port = port;
- this.user = u;
- this.pass = pw;
- try {
- conn = DriverManager.getConnection(
- "jdbc:mysql://"+ this.ip + ":" + this.port + "",
- this.user, this.pass);
- conn.setAutoCommit(true);
- st = conn.createStatement();
- System.out.print("OK, Connected with " + this.user);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- public static void main(String[] args) {
- String add, p, usr, pw;
- Scanner sc = new Scanner(System.in);
- System.out.println("Escribir IP: ");
- add = sc.nextLine();
- System.out.println("Escribir PORT: ");
- p = sc.nextLine();
- System.out.println("Escribir USER: ");
- usr = sc.nextLine();
- System.out.println("Escribir PASSWORD: ");
- pw = sc.nextLine();
- launcher data = new launcher(add, p, usr, pw);
- //launcher data = new launcher("192.168.56.11", "3306", "dummy", "foobar2020");
- int x = ThreadLocalRandom.current().nextInt(0, 11);
- System.out.print(x);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement