package feedmeyoutubecore.helper;

import feedmeyoutubecore.Main;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Connection;
import java.sql.DriverManager;

public class DbConnector {
    // The Logger
    private static final Logger Log = LoggerFactory.getLogger(Main.class);

    // Configuration
    private static String dbHost = "localhost";
    private static String dbName = "webseite";
    private static String dbDriver = "com.mysql.jdbc.Driver";
    private static String dbUser = "YtbUser";
    private static String dbPass = "12345"; // Only for testing, for god's sake, secure your Database better than me :O

    public static Connection Connect()
    {
        try {
            Class.forName(dbDriver);

            return DriverManager.getConnection("jdbc:mysql://" + dbHost + "/" + dbName, dbUser, dbPass);
        }

        catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}

@@ -28,16 +28,52 @@
 elper;%0A%0A
+import feedmeyoutubecore.AppConfig;%0A
 import f
@@ -211,16 +211,57 @@
 Manager;
+%0Aimport org.aeonbits.owner.ConfigFactory;
 %0A%0Apublic
@@ -373,16 +373,99 @@
 .class);
+%0A    private static final AppConfig CONFIG = ConfigFactory.create(AppConfig.class);
 %0A%0A    //
@@ -490,32 +490,38 @@
  private static 
+final 
 String dbHost = 
@@ -524,19 +524,26 @@
 t = 
-%22localhost%22
+CONFIG.mysqlHost()
 ;%0A  
@@ -551,32 +551,38 @@
  private static 
+final 
 String dbName = 
@@ -585,18 +585,24 @@
 e = 
-%22webseite%22
+CONFIG.mysqlDb()
 ;%0A  
@@ -610,32 +610,38 @@
  private static 
+final 
 String dbDriver 
@@ -646,31 +646,28 @@
 r = 
-%22com.mysql.jdbc.
+CONFIG.mysql
 Driver
-%22
+()
 ;%0A  
@@ -675,32 +675,38 @@
  private static 
+final 
 String dbUser = 
@@ -709,17 +709,26 @@
 r = 
-%22Ytb
+CONFIG.mysql
 User
-%22
+()
 ;%0A  
@@ -744,16 +744,22 @@
  static 
+final 
 String d
@@ -770,92 +770,31 @@
 s = 
-%2212345%22; // Only for testing, for god's sake, secure your Database better than me :O
+CONFIG.mysqlPassword();
 %0A%0A  

Read config from config file.