package stream.flarebot.flarebot.util;

import com.mysql.cj.jdbc.MysqlDataSource;
import stream.flarebot.flarebot.FlareBot;

import javax.naming.Context;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * <br>
 * Created by Arsen on 29.10.16..
 */
public class SQLController {

    private static final Context context = null;
    private static final MysqlDataSource dataSource;
    private static final AtomicInteger COUNTER = new AtomicInteger(0);
    private static final ExecutorService SQL_POOL = Executors
            .newCachedThreadPool(r -> new Thread(r, "SQL Thread " + COUNTER.incrementAndGet()));

    static {
        dataSource = new MysqlDataSource();
        dataSource.setPassword(FlareBot.passwd);
        dataSource.setDatabaseName("flarebot");
        dataSource.setPort(3306);
        dataSource.setPortNumber(3306);
        dataSource.setServerName("localhost");
        dataSource.setUser("flare");
        dataSource.setURL(dataSource
                .getURL() + "?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&autoReconnect=true&useSSL=false");
        dataSource.setUrl(dataSource
                .getUrl() + "?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&autoReconnect=true&useSSL=false");
    }

    private static Connection getConnection() throws SQLException {
        return dataSource.getConnection();
    }

    public static void runSqlTask(SQLTask toRun) throws SQLException {
        Connection c = getConnection();
        toRun.execute(c);
        if (!c.isClosed())
            c.close();
    }

    public static void asyncRunSqlTask(SQLTask toRun) {
        SQL_POOL.submit(() -> {
            try {
                runSqlTask(toRun);
            } catch (Exception e) {
                FlareBot.LOGGER.error("Exception in " + Thread.currentThread().getName(), e);
            }
        });
    }
}

@@ -44,83 +44,83 @@
 ort 
-com.mysql.cj.jdbc.MysqlDataSource;%0Aimport stream.flarebot.flarebot.FlareBot
+stream.flarebot.flarebot.FlareBot;%0Aimport com.mysql.cj.jdbc.MysqlDataSource
 ;%0A%0Ai
@@ -654,29 +654,16 @@
 xecutors
-%0A            
 .newCach
@@ -1006,17 +1006,17 @@
 me(%22
-localhost
+127.0.0.1
 %22);%0A
@@ -1088,33 +1088,16 @@
 taSource
-%0A                
 .getURL(
@@ -1271,33 +1271,16 @@
 taSource
-%0A                
 .getUrl(

Fix sql