package me.jesensky.dan.playertracker.util;

import com.mysql.jdbc.MySQLConnection;
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DatabaseManager {
    private Connection connection;
    private String host;
    private String username;
    private String password;
    private String table;
    private String db;
    private int port;

    public DatabaseManager(String host, int port, String user, String password, String table, String db, String defaults) throws SQLException {
        this.host = host;
        this.port = port;
        this.username = user;
        this.password = password;
        this.table = table;
        this.db = db;
        this.connect(defaults);
    }

    private void connect(String defaults){
        MysqlDataSource d = new MysqlDataSource();
        d.setUser(this.username);
        d.setPassword(this.password);
        d.setServerName(this.host);
        d.setPort(this.port);
        d.setDatabaseName(this.db);
    }

    private void connect(){

    }
}
@@ -42,47 +42,8 @@
 l;%0A%0A
-import com.mysql.jdbc.MySQLConnection;%0A
 impo
@@ -97,37 +97,8 @@
 e;%0A%0A
-import javax.sql.DataSource;%0A
 impo
@@ -141,21 +141,25 @@
 sql.
-DriverManager
+PreparedStatement
 ;%0Aim
@@ -406,16 +406,322 @@
 nt port;
+%0A    public static final String PLAYER_DB_DEFAULT = %22SELECT * FROM information_schema.tables WHERE table_schema = '?' AND table_name = 'players' LIMIT 1;%22;%0A    public static final String USER_DB_DEFAULT = %22SELECT * FROM information_schema.tables WHERE table_schema = '?' AND table_name = 'users' LIMIT 1;%22;
 %0A%0A    pu
@@ -797,22 +797,8 @@
 ord,
- String table,
  Str
@@ -812,24 +812,21 @@
  String 
-defaults
+table
 ) throws
@@ -841,16 +841,33 @@
 ption %7B%0A
+        super();%0A
         
@@ -1032,84 +1032,538 @@
     
-    this.connect(defaults);%0A    %7D%0A%0A    private void connect(String defaults)
+%7D%0A%0A    public void connect(String defaults, String... args) throws SQLException%7B%0A        this.connect();%0A        PreparedStatement statement = this.connection.prepareStatement(defaults);%0A        for(int x = 0; x %3C args.length; x++)%0A            try %7B%0A                statement.setInt(x, Integer.parseInt(args%5Bx%5D));%0A            %7Dcatch(NumberFormatException e)%7B%0A                statement.setString(x, args%5Bx%5D);%0A            %7D%0A        statement.execute();%0A        statement.close();%0A    %7D%0A%0A    public void connect() throws SQLException
 %7B%0A  
@@ -1793,39 +1793,188 @@
     
-%7D%0A%0A    private void connect()%7B%0A
+    this.connection = d.getConnection();%0A    %7D%0A%0A    public PreparedStatement prepareStatement(String sql) throws SQLException%7B%0A        return this.connection.prepareStatement(sql);
 %0A   

Rewrite part of how the database manager works (specifically defaults)