Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.trow.TGEssentials.MySQL;
- import java.sql.*;
- public class MySQL extends Database
- {
- private final String user;
- private final String database;
- private final String password;
- private final String port;
- private final String hostname;
- public MySQL(final String hostname, final String port, final String database, final String username, final String password) {
- this.hostname = hostname;
- this.port = port;
- this.database = database;
- this.user = username;
- this.password = password;
- }
- @Override
- public Connection openConnection() throws SQLException, ClassNotFoundException {
- if (this.checkConnection()) {
- return this.connection;
- }
- Class.forName("com.mysql.jdbc.Driver");
- return this.connection = DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password);
- }
- public String getUser() {
- return this.user;
- }
- public String getHostname() {
- return this.hostname;
- }
- public String getDatabase() {
- return this.database;
- }
- public String getPassword() {
- return this.password;
- }
- }
Add Comment
Please, Sign In to add comment