Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Database;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class Connect {
- public Connection conn = null;
- public Statement stmt = null;
- public ResultSet rs = null;
- private String IP = "Localhost";
- private String DB = "abccarrental";
- private String UN = "root";
- private String PW = "";
- private String HT;
- public Connect() {
- this.HT = "jdbc:mysql://" + this.IP + "/" + this.DB;
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- System.out.println("[INFO] : Connecting to " + this.DB + "'s database...");
- this.conn = DriverManager.getConnection(this.HT, this.UN, this.PW);
- System.out.println(" > IP: " + this.IP + " | DB: " + this.DB + " | UN: " + this.UN + " | PW: " + this.PW);
- System.out.println(" > HT: " + this.HT);
- System.out.println(" > DDS: " + this.conn);
- this.stmt = this.conn.createStatement();
- } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | SQLException var2) {
- System.out.println("[ERROR] : " + var2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement