Quellcode durchsuchen

Unhardcoding database connection

Zoey76 vor 6 Jahren
Ursprung
Commit
117a161635
50 geänderte Dateien mit 244 neuen und 493 gelöschten Zeilen
  1. 18 11
      pom.xml
  2. 1 0
      src/main/java/com/l2jserver/cli/L2JServerCLI.java
  3. 1 0
      src/main/java/com/l2jserver/cli/command/AbstractCommand.java
  4. 1 0
      src/main/java/com/l2jserver/cli/command/AccountCommand.java
  5. 1 0
      src/main/java/com/l2jserver/cli/command/BuildCommand.java
  6. 1 0
      src/main/java/com/l2jserver/cli/command/CodeCommand.java
  7. 1 0
      src/main/java/com/l2jserver/cli/command/ConfigurationEditorGUICommand.java
  8. 1 0
      src/main/java/com/l2jserver/cli/command/DatabaseCommand.java
  9. 1 0
      src/main/java/com/l2jserver/cli/command/DeployCommand.java
  10. 1 0
      src/main/java/com/l2jserver/cli/command/GameServerCommand.java
  11. 1 0
      src/main/java/com/l2jserver/cli/command/HelpCommand.java
  12. 1 0
      src/main/java/com/l2jserver/cli/command/QuitCommand.java
  13. 1 0
      src/main/java/com/l2jserver/cli/command/account/AccountCreateCommand.java
  14. 1 0
      src/main/java/com/l2jserver/cli/command/account/AccountDeleteCommand.java
  15. 1 0
      src/main/java/com/l2jserver/cli/command/account/AccountListCommand.java
  16. 1 0
      src/main/java/com/l2jserver/cli/command/account/AccountUpdateCommand.java
  17. 32 32
      src/main/java/com/l2jserver/cli/command/database/DatabaseInstallCommand.java
  18. 1 0
      src/main/java/com/l2jserver/cli/command/gameserver/GameServerListCommand.java
  19. 1 0
      src/main/java/com/l2jserver/cli/command/gameserver/GameServerRegisterCommand.java
  20. 1 0
      src/main/java/com/l2jserver/cli/command/gameserver/GameServerUnregisterCommand.java
  21. 0 63
      src/main/java/com/l2jserver/cli/config/Configs.java
  22. 18 16
      src/main/java/com/l2jserver/cli/config/Configuration.java
  23. 9 2
      src/main/java/com/l2jserver/cli/config/GameServerConfiguration.java
  24. 9 2
      src/main/java/com/l2jserver/cli/config/LoginServerConfiguration.java
  25. 35 0
      src/main/java/com/l2jserver/cli/config/ServerConfiguration.java
  26. 0 96
      src/main/java/com/l2jserver/cli/config/impl/DatabaseConfigurationImpl.java
  27. 0 42
      src/main/java/com/l2jserver/cli/config/impl/GameServerConfigurationImpl.java
  28. 0 42
      src/main/java/com/l2jserver/cli/config/impl/LoginServerConfigurationImpl.java
  29. 18 35
      src/main/java/com/l2jserver/cli/dao/AbstractDAO.java
  30. 6 4
      src/main/java/com/l2jserver/cli/dao/AbstractDatabaseDAO.java
  31. 4 2
      src/main/java/com/l2jserver/cli/dao/AccountDAO.java
  32. 4 3
      src/main/java/com/l2jserver/cli/dao/GameServerDAO.java
  33. 4 3
      src/main/java/com/l2jserver/cli/dao/GameServerDatabaseDAO.java
  34. 3 2
      src/main/java/com/l2jserver/cli/dao/LoginServerDatabaseDAO.java
  35. 1 0
      src/main/java/com/l2jserver/cli/model/AccountListType.java
  36. 1 0
      src/main/java/com/l2jserver/cli/model/CloneType.java
  37. 1 0
      src/main/java/com/l2jserver/cli/model/DatabaseInstallType.java
  38. 1 0
      src/main/java/com/l2jserver/cli/model/ServerNames.java
  39. 1 0
      src/main/java/com/l2jserver/cli/model/ServerType.java
  40. 1 0
      src/main/java/com/l2jserver/cli/util/FileWriterStdout.java
  41. 1 0
      src/main/java/com/l2jserver/cli/util/LoggerProgressMonitor.java
  42. 1 0
      src/main/java/com/l2jserver/cli/util/SQLFilter.java
  43. 1 0
      src/main/java/com/l2jserver/gui/editor/ConfigUserInterface.java
  44. 2 0
      src/main/java/com/l2jserver/gui/editor/JIPTextField.java
  45. 0 13
      src/main/resources/config.properties
  46. 27 0
      src/main/resources/config/game-server.properties
  47. 27 0
      src/main/resources/config/login-server.properties
  48. 1 1
      src/main/resources/log4j2.xml
  49. 0 115
      src/main/resources/sql/cleanup/gs_cleanup.sql
  50. 0 9
      src/main/resources/sql/cleanup/ls_cleanup.sql

+ 18 - 11
pom.xml

@@ -15,14 +15,20 @@
 		<slf4j.version>1.7.25</slf4j.version>
 		<log4j.version>2.11.1</log4j.version>
 		<mysql-connector-java.version>8.0.15</mysql-connector-java.version>
-		<commons-configuration2.version>2.4</commons-configuration2.version>
-		<commons-beanutils.version>1.9.3</commons-beanutils.version>
 		<asciitable.version>0.3.2</asciitable.version>
+		<owner.version>1.0.10</owner.version>
+		<l2j-server-commons.version>2.6.1.1</l2j-server-commons.version>
 		<!-- Plugins -->
 		<maven-dependency-plugin.version>3.1.1</maven-dependency-plugin.version>
 		<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
 		<maven-assembly-plugin.version>3.1.1</maven-assembly-plugin.version>
 	</properties>
+	<repositories>
+		<repository>
+			<id>jitpack.io</id>
+			<url>https://jitpack.io</url>
+		</repository>
+	</repositories>
 	<dependencies>
 		<dependency>
 			<groupId>info.picocli</groupId>
@@ -55,19 +61,20 @@
 			<version>${mysql-connector-java.version}</version>
 		</dependency>
 		<dependency>
-			<groupId>org.apache.commons</groupId>
-			<artifactId>commons-configuration2</artifactId>
-			<version>${commons-configuration2.version}</version>
+			<groupId>de.vandermeer</groupId>
+			<artifactId>asciitable</artifactId>
+			<version>${asciitable.version}</version>
 		</dependency>
 		<dependency>
-			<groupId>commons-beanutils</groupId>
-			<artifactId>commons-beanutils</artifactId>
-			<version>${commons-beanutils.version}</version>
+			<groupId>org.aeonbits.owner</groupId>
+			<artifactId>owner-java8</artifactId>
+			<version>${owner.version}</version>
 		</dependency>
+		<!-- L2J -->
 		<dependency>
-			<groupId>de.vandermeer</groupId>
-			<artifactId>asciitable</artifactId>
-			<version>${asciitable.version}</version>
+			<groupId>org.bitbucket.l2jserver</groupId>
+			<artifactId>l2j-server-commons</artifactId>
+			<version>${l2j-server-commons.version}</version>
 		</dependency>
 	</dependencies>
 	<build>

+ 1 - 0
src/main/java/com/l2jserver/cli/L2JServerCLI.java

@@ -38,6 +38,7 @@ import picocli.CommandLine.Command;
 /**
  * L2J Server CLI.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "l2jcli", version = "1.0", subcommands = {
 	CodeCommand.class,

+ 1 - 0
src/main/java/com/l2jserver/cli/command/AbstractCommand.java

@@ -24,6 +24,7 @@ import java.io.IOException;
 /**
  * Abstract command.
  * @author Zoey76
+ * @version 1.0.0
  */
 public abstract class AbstractCommand implements Runnable {
 	protected static final String YES = "y";

+ 1 - 0
src/main/java/com/l2jserver/cli/command/AccountCommand.java

@@ -29,6 +29,7 @@ import picocli.CommandLine.Command;
 /**
  * Account command.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "account", aliases = "a", subcommands = {
 	AccountCreateCommand.class,

+ 1 - 0
src/main/java/com/l2jserver/cli/command/BuildCommand.java

@@ -23,6 +23,7 @@ import picocli.CommandLine.Command;
 /**
  * Build command.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "build", aliases = "b")
 public class BuildCommand extends AbstractCommand {

+ 1 - 0
src/main/java/com/l2jserver/cli/command/CodeCommand.java

@@ -33,6 +33,7 @@ import picocli.CommandLine.Option;
 /**
  * Code command.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "code", aliases = "c")
 public class CodeCommand extends AbstractCommand {

+ 1 - 0
src/main/java/com/l2jserver/cli/command/ConfigurationEditorGUICommand.java

@@ -28,6 +28,7 @@ import picocli.CommandLine.Command;
 /**
  * Configuration Editor GUI command.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "config", aliases = "gui")
 public class ConfigurationEditorGUICommand extends AbstractCommand {

+ 1 - 0
src/main/java/com/l2jserver/cli/command/DatabaseCommand.java

@@ -26,6 +26,7 @@ import picocli.CommandLine.Command;
 /**
  * Database command.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "database", aliases = "db", subcommands = {
 	DatabaseInstallCommand.class

+ 1 - 0
src/main/java/com/l2jserver/cli/command/DeployCommand.java

@@ -23,6 +23,7 @@ import picocli.CommandLine.Command;
 /**
  * Deploy command.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "deploy", aliases = "d")
 public class DeployCommand extends AbstractCommand {

+ 1 - 0
src/main/java/com/l2jserver/cli/command/GameServerCommand.java

@@ -28,6 +28,7 @@ import picocli.CommandLine.Command;
 /**
  * Game Server command implementation.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "gameserver", aliases = "gs", subcommands = {
 	GameServerRegisterCommand.class,

+ 1 - 0
src/main/java/com/l2jserver/cli/command/HelpCommand.java

@@ -23,6 +23,7 @@ import picocli.CommandLine.Command;
 /**
  * Help command.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "help", aliases = "h")
 public class HelpCommand extends AbstractCommand {

+ 1 - 0
src/main/java/com/l2jserver/cli/command/QuitCommand.java

@@ -23,6 +23,7 @@ import picocli.CommandLine.Command;
 /**
  * Quit command.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "quit", aliases = "q")
 public class QuitCommand extends AbstractCommand {

+ 1 - 0
src/main/java/com/l2jserver/cli/command/account/AccountCreateCommand.java

@@ -27,6 +27,7 @@ import picocli.CommandLine.Option;
 /**
  * Account create command.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "create")
 public class AccountCreateCommand extends AbstractCommand {

+ 1 - 0
src/main/java/com/l2jserver/cli/command/account/AccountDeleteCommand.java

@@ -29,6 +29,7 @@ import picocli.CommandLine.Option;
 /**
  * Account delete command.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "delete")
 public class AccountDeleteCommand extends AbstractCommand {

+ 1 - 0
src/main/java/com/l2jserver/cli/command/account/AccountListCommand.java

@@ -28,6 +28,7 @@ import picocli.CommandLine.Option;
 /**
  * Account list command.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "list")
 public class AccountListCommand extends AbstractCommand {

+ 1 - 0
src/main/java/com/l2jserver/cli/command/account/AccountUpdateCommand.java

@@ -27,6 +27,7 @@ import picocli.CommandLine.Option;
 /**
  * Account update command.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "update")
 public class AccountUpdateCommand extends AbstractCommand {

+ 32 - 32
src/main/java/com/l2jserver/cli/command/database/DatabaseInstallCommand.java

@@ -21,9 +21,10 @@ package com.l2jserver.cli.command.database;
 import java.io.File;
 import java.util.Scanner;
 
+import org.aeonbits.owner.Mutable;
+
 import com.l2jserver.cli.command.AbstractCommand;
-import com.l2jserver.cli.config.Configs;
-import com.l2jserver.cli.config.DatabaseConfiguration;
+import com.l2jserver.cli.config.Configuration;
 import com.l2jserver.cli.dao.AbstractDatabaseDAO;
 import com.l2jserver.cli.dao.GameServerDatabaseDAO;
 import com.l2jserver.cli.dao.LoginServerDatabaseDAO;
@@ -36,45 +37,46 @@ import picocli.CommandLine.Option;
 /**
  * Database install command.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "install")
 public class DatabaseInstallCommand extends AbstractCommand {
 	
 	@Option(names = {
 		"-l",
-		"--location"
+		"--sql-location"
 	}, required = true, description = "Files location")
 	private String path;
 	
 	@Option(names = {
-		"-h",
-		"--host"
-	}, description = "Database host")
-	private String host;
+		"-dv",
+		"--database-driver"
+	}, description = "Database Driver")
+	private String driver;
 	
 	@Option(names = {
-		"-p",
-		"--port"
-	}, description = "Database port")
-	private Integer port;
+		"-url",
+		"--database-url"
+	}, description = "Database URL")
+	private String url;
 	
 	@Option(names = {
 		"-u",
-		"--user"
-	}, description = "Database user")
+		"--database-user"
+	}, description = "Database User")
 	private String user;
 	
 	@Option(names = {
 		"-pw",
-		"--password"
-	}, description = "Database password")
+		"--database-password"
+	}, description = "Database Password")
 	private String password;
 	
 	@Option(names = {
-		"-d",
-		"--db"
-	}, description = "Database name")
-	private String database;
+		"-pool",
+		"--connection-pool"
+	}, description = "Connection Pool")
+	private String connectionPool;
 	
 	@Option(names = {
 		"-m",
@@ -99,8 +101,6 @@ public class DatabaseInstallCommand extends AbstractCommand {
 		
 		final AbstractDatabaseDAO databaseDAO = databaseDAO();
 		
-		databaseDAO.ensureDatabaseUsage();
-		
 		databaseDAO.createDump();
 		
 		databaseDAO.updates(mode, sqlPath);
@@ -127,36 +127,36 @@ public class DatabaseInstallCommand extends AbstractCommand {
 	private AbstractDatabaseDAO databaseDAO() {
 		switch (serverType) {
 			case GAME: {
-				overrideConfigs(Configs.gameServer().db());
+				overrideConfigs(Configuration.gameServer());
 				return new GameServerDatabaseDAO();
 			}
 			default:
 			case LOGIN: {
-				overrideConfigs(Configs.loginServer().db());
+				overrideConfigs(Configuration.loginServer());
 				return new LoginServerDatabaseDAO();
 			}
 		}
 	}
 	
-	private void overrideConfigs(DatabaseConfiguration databaseConfiguration) {
-		if (host != null) {
-			databaseConfiguration.withHost(host);
+	private void overrideConfigs(Mutable databaseConfiguration) {
+		if (driver != null) {
+			databaseConfiguration.setProperty("DatabaseDriver", driver);
 		}
 		
-		if (port != null) {
-			databaseConfiguration.withPort(port);
+		if (url != null) {
+			databaseConfiguration.setProperty("DatabaseURL", url);
 		}
 		
 		if (user != null) {
-			databaseConfiguration.withUser(user);
+			databaseConfiguration.setProperty("DatabaseUser", user);
 		}
 		
 		if (password != null) {
-			databaseConfiguration.withPassword(password);
+			databaseConfiguration.setProperty("DatabasePassword", password);
 		}
 		
-		if (database != null) {
-			databaseConfiguration.withName(database);
+		if (connectionPool != null) {
+			databaseConfiguration.setProperty("DatabaseConnectionPool", connectionPool);
 		}
 	}
 }

+ 1 - 0
src/main/java/com/l2jserver/cli/command/gameserver/GameServerListCommand.java

@@ -31,6 +31,7 @@ import picocli.CommandLine.Option;
 /**
  * Game Server list command.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "list", aliases = "l", description = "Lists all game servers from login server.")
 public class GameServerListCommand extends AbstractCommand {

+ 1 - 0
src/main/java/com/l2jserver/cli/command/gameserver/GameServerRegisterCommand.java

@@ -38,6 +38,7 @@ import picocli.CommandLine.Option;
 /**
  * Game Server register command.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "register", aliases = "r", description = "Adds a game server to the login server.")
 public class GameServerRegisterCommand extends AbstractCommand {

+ 1 - 0
src/main/java/com/l2jserver/cli/command/gameserver/GameServerUnregisterCommand.java

@@ -27,6 +27,7 @@ import picocli.CommandLine.Option;
 /**
  * Game Server unregister command.
  * @author Zoey76
+ * @version 1.0.0
  */
 @Command(name = "unregister", aliases = "u", description = "Removes a game server from the login server.")
 public class GameServerUnregisterCommand extends AbstractCommand {

+ 0 - 63
src/main/java/com/l2jserver/cli/config/Configs.java

@@ -1,63 +0,0 @@
-/*
- * Copyright © 2019 L2J Server
- *
- * This file is part of L2J Server.
- *
- * L2J Server is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * L2J Server is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.cli.config;
-
-import java.io.File;
-
-import org.apache.commons.configuration2.Configuration;
-import org.apache.commons.configuration2.builder.fluent.Configurations;
-
-import com.l2jserver.cli.config.impl.GameServerConfigurationImpl;
-import com.l2jserver.cli.config.impl.LoginServerConfigurationImpl;
-
-/**
- * Configs.
- * @author Zoey76
- */
-public enum Configs {
-	INSTANCE;
-	
-	private Configuration config;
-	
-	private GameServerConfiguration gameServerConfig;
-	
-	private LoginServerConfiguration loginServerConfiguration;
-	
-	Configs() {
-		final var configs = new Configurations();
-		try {
-			config = configs.properties(new File("config.properties"));
-			
-			gameServerConfig = new GameServerConfigurationImpl(config);
-			
-			loginServerConfiguration = new LoginServerConfigurationImpl(config);
-		} catch (Exception ex) {
-			System.err.println("There has been an error loading configs!");
-			ex.printStackTrace();
-		}
-	}
-	
-	public static GameServerConfiguration gameServer() {
-		return INSTANCE.gameServerConfig;
-	}
-	
-	public static LoginServerConfiguration loginServer() {
-		return INSTANCE.loginServerConfiguration;
-	}
-}

+ 18 - 16
src/main/java/com/l2jserver/cli/config/DatabaseConfiguration.java → src/main/java/com/l2jserver/cli/config/Configuration.java

@@ -18,29 +18,31 @@
  */
 package com.l2jserver.cli.config;
 
+import org.aeonbits.owner.ConfigFactory;
+
 /**
- * Database configuration interface.
+ * Configuration.
  * @author Zoey76
+ * @version 1.0.0
  */
-public interface DatabaseConfiguration {
-	
-	String name();
-	
-	String host();
-	
-	int port();
-	
-	String user();
+public enum Configuration {
 	
-	String password();
+	INSTANCE;
 	
-	DatabaseConfiguration withName(String name);
+	private LoginServerConfiguration loginServer;
 	
-	DatabaseConfiguration withHost(String host);
+	private GameServerConfiguration gameServer;
 	
-	DatabaseConfiguration withPort(int port);
+	private Configuration() {
+		loginServer = ConfigFactory.create(LoginServerConfiguration.class);
+		gameServer = ConfigFactory.create(GameServerConfiguration.class);
+	}
 	
-	DatabaseConfiguration withUser(String user);
+	public static LoginServerConfiguration loginServer() {
+		return INSTANCE.loginServer;
+	}
 	
-	DatabaseConfiguration withPassword(String password);
+	public static GameServerConfiguration gameServer() {
+		return INSTANCE.gameServer;
+	}
 }

+ 9 - 2
src/main/java/com/l2jserver/cli/config/GameServerConfiguration.java

@@ -18,10 +18,17 @@
  */
 package com.l2jserver.cli.config;
 
+import org.aeonbits.owner.Config.Sources;
+
 /**
  * Game Server configuration interface.
  * @author Zoey76
+ * @version 1.0.0
  */
-public interface GameServerConfiguration {
-	DatabaseConfiguration db();
+@Sources({
+	"file:./config/game-server.properties",
+	"classpath:config/game-server.properties"
+})
+public interface GameServerConfiguration extends ServerConfiguration {
+	
 }

+ 9 - 2
src/main/java/com/l2jserver/cli/config/LoginServerConfiguration.java

@@ -18,10 +18,17 @@
  */
 package com.l2jserver.cli.config;
 
+import org.aeonbits.owner.Config.Sources;
+
 /**
  * Login Server configuration interface.
  * @author Zoey76
+ * @version 1.0.0
  */
-public interface LoginServerConfiguration {
-	DatabaseConfiguration db();
+@Sources({
+	"file:./config/login-server.properties",
+	"classpath:config/login-server.properties"
+})
+public interface LoginServerConfiguration extends ServerConfiguration {
+	
 }

+ 35 - 0
src/main/java/com/l2jserver/cli/config/ServerConfiguration.java

@@ -0,0 +1,35 @@
+package com.l2jserver.cli.config;
+
+import org.aeonbits.owner.Mutable;
+
+/**
+ * ServerConfiguration.
+ * @author Zoey76
+ * @version 2.6.1.0
+ */
+public interface ServerConfiguration extends Mutable {
+	
+	@Key("DatabaseDriver")
+	String getDatabaseDriver();
+	
+	@Key("DatabaseURL")
+	String getDatabaseURL();
+	
+	@Key("DatabaseName")
+	String getDatabaseName();
+	
+	@Key("DatabaseUser")
+	String getDatabaseUser();
+	
+	@Key("DatabasePassword")
+	String getDatabasePassword();
+	
+	@Key("DatabaseConnectionPool")
+	String getDatabaseConnectionPool();
+	
+	@Key("DatabaseMaximumPoolSize")
+	int getDatabaseMaximumPoolSize();
+	
+	@Key("DatabaseMaximumIdleTime")
+	int getDatabaseMaximumIdleTime();
+}

+ 0 - 96
src/main/java/com/l2jserver/cli/config/impl/DatabaseConfigurationImpl.java

@@ -1,96 +0,0 @@
-/*
- * Copyright © 2019 L2J Server
- *
- * This file is part of L2J Server.
- *
- * L2J Server is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * L2J Server is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.cli.config.impl;
-
-import org.apache.commons.configuration2.Configuration;
-
-import com.l2jserver.cli.config.DatabaseConfiguration;
-
-/**
- * Database configuration implementation.
- * @author Zoey76
- */
-public class DatabaseConfigurationImpl implements DatabaseConfiguration {
-	
-	private static final String PREFIX = ".db.";
-	
-	private String section;
-	
-	private Configuration config;
-	
-	public DatabaseConfigurationImpl(String section, Configuration config) {
-		this.config = config;
-		this.section = section;
-	}
-	
-	@Override
-	public String name() {
-		return config.getString(section + PREFIX + "name");
-	}
-	
-	@Override
-	public String host() {
-		return config.getString(section + PREFIX + "host");
-	}
-	
-	@Override
-	public int port() {
-		return config.getInt(section + PREFIX + "port");
-	}
-	
-	@Override
-	public String user() {
-		return config.getString(section + PREFIX + "user");
-	}
-	
-	@Override
-	public String password() {
-		return config.getString(section + PREFIX + "password");
-	}
-	
-	@Override
-	public DatabaseConfiguration withName(String name) {
-		config.setProperty(section + PREFIX + "name", name);
-		return this;
-	}
-	
-	@Override
-	public DatabaseConfiguration withHost(String host) {
-		config.setProperty(section + PREFIX + "host", host);
-		return this;
-	}
-	
-	@Override
-	public DatabaseConfiguration withPort(int port) {
-		config.setProperty(section + PREFIX + "port", port);
-		return this;
-	}
-	
-	@Override
-	public DatabaseConfiguration withUser(String user) {
-		config.setProperty(section + PREFIX + "user", user);
-		return this;
-	}
-	
-	@Override
-	public DatabaseConfiguration withPassword(String password) {
-		config.setProperty(section + PREFIX + "password", password);
-		return this;
-	}
-}

+ 0 - 42
src/main/java/com/l2jserver/cli/config/impl/GameServerConfigurationImpl.java

@@ -1,42 +0,0 @@
-/*
- * Copyright © 2019 L2J Server
- *
- * This file is part of L2J Server.
- *
- * L2J Server is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * L2J Server is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.cli.config.impl;
-
-import org.apache.commons.configuration2.Configuration;
-
-import com.l2jserver.cli.config.DatabaseConfiguration;
-import com.l2jserver.cli.config.GameServerConfiguration;
-
-/**
- * Game Server configuration implementation.
- * @author Zoey76
- */
-public class GameServerConfigurationImpl implements GameServerConfiguration {
-	
-	private DatabaseConfiguration databaseConfiguration;
-	
-	public GameServerConfigurationImpl(Configuration config) {
-		databaseConfiguration = new DatabaseConfigurationImpl("gs", config);
-	}
-	
-	@Override
-	public DatabaseConfiguration db() {
-		return databaseConfiguration;
-	}
-}

+ 0 - 42
src/main/java/com/l2jserver/cli/config/impl/LoginServerConfigurationImpl.java

@@ -1,42 +0,0 @@
-/*
- * Copyright © 2019 L2J Server
- *
- * This file is part of L2J Server.
- *
- * L2J Server is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * L2J Server is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.cli.config.impl;
-
-import org.apache.commons.configuration2.Configuration;
-
-import com.l2jserver.cli.config.DatabaseConfiguration;
-import com.l2jserver.cli.config.LoginServerConfiguration;
-
-/**
- * Login Server configuration implementation.
- * @author Zoey76
- */
-public class LoginServerConfigurationImpl implements LoginServerConfiguration {
-	
-	private DatabaseConfiguration databaseConfiguration;
-	
-	public LoginServerConfigurationImpl(Configuration config) {
-		databaseConfiguration = new DatabaseConfigurationImpl("ls", config);
-	}
-	
-	@Override
-	public DatabaseConfiguration db() {
-		return databaseConfiguration;
-	}
-}

+ 18 - 35
src/main/java/com/l2jserver/cli/dao/AbstractDAO.java

@@ -21,67 +21,50 @@ package com.l2jserver.cli.dao;
 import java.io.File;
 import java.io.FileWriter;
 import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
-import java.util.Properties;
 import java.util.Scanner;
 
+import com.l2jserver.cli.config.ServerConfiguration;
 import com.l2jserver.cli.util.FileWriterStdout;
 import com.l2jserver.cli.util.SQLFilter;
+import com.l2jserver.commons.database.ConnectionFactory;
 
 /**
  * Abstract DAO.
  * @author Zoey76
+ * @version 1.0.0
  */
 class AbstractDAO {
 	
 	private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss");
 	
-	private final String host;
+	private String database;
 	
-	private final int port;
-	
-	private final String database;
-	
-	private final Properties info;
-	
-	AbstractDAO(String host, int port, String database, String username, String password) {
-		this.host = host;
-		this.port = port;
-		this.database = database;
-		info = new Properties();
-		info.put("user", username);
-		info.put("password", password);
-		info.put("useSSL", "false");
-		info.put("serverTimezone", "UTC");
-		info.put("allowPublicKeyRetrieval", "true");
+	AbstractDAO(ServerConfiguration server) {
+		this.database = server.getDatabaseName();
+		
+		ConnectionFactory.builder() //
+			.withDriver(server.getDatabaseDriver()) //
+			.withUrl(server.getDatabaseURL()) //
+			.withUser(server.getDatabaseUser()) //
+			.withPassword(server.getDatabasePassword()) //
+			.withConnectionPool(server.getDatabaseConnectionPool()) //
+			.withMaxPoolSize(server.getDatabaseMaximumPoolSize()) //
+			.withMaxIdleTime(server.getDatabaseMaximumIdleTime()) //
+			.build();
 	}
 	
 	public String getDatabase() {
 		return database;
 	}
 	
-	protected Connection getConnection() throws SQLException {
-		final String url = String.format("jdbc:mysql://%s:%s/%s", host, port, database);
-		return DriverManager.getConnection(url, info);
-	}
-	
-	public void ensureDatabaseUsage() {
-		final String url = String.format("jdbc:mysql://%s:%s", host, port);
-		try (var con = DriverManager.getConnection(url, info); //
-			var s = con.createStatement()) {
-			s.execute("CREATE DATABASE IF NOT EXISTS `" + database + "`");
-			s.execute("USE `" + database + "`");
-		} catch (Exception ex) {
-			System.err.println("There has been an error ensuring database " + database + " usage!");
-			ex.printStackTrace();
-		}
+	public Connection getConnection() {
+		return ConnectionFactory.getInstance().getConnection();
 	}
 	
 	public void executeSQLScript(File file) {

+ 6 - 4
src/main/java/com/l2jserver/cli/dao/AbstractDatabaseDAO.java

@@ -21,19 +21,21 @@ package com.l2jserver.cli.dao;
 import java.io.File;
 import java.util.prefs.Preferences;
 
+import com.l2jserver.cli.config.ServerConfiguration;
 import com.l2jserver.cli.model.DatabaseInstallType;
 import com.l2jserver.cli.util.SQLFilter;
 
 /**
  * Database DAO.
  * @author Zoey76
+ * @version 1.0.0
  */
 public abstract class AbstractDatabaseDAO extends AbstractDAO {
 	
-	AbstractDatabaseDAO(String host, int port, String database, String username, String password) {
-		super(host, port, database, username, password);
+	AbstractDatabaseDAO(ServerConfiguration server) {
+		super(server);
 	}
-	
+
 	public void mods(File sqlPath) {
 		final var modsPath = new File(sqlPath, "mods");
 		if (modsPath.exists()) {
@@ -64,7 +66,7 @@ public abstract class AbstractDatabaseDAO extends AbstractDAO {
 			case FULL: {
 				System.out.println("Executing cleanup script...");
 				
-				runSQLFiles(new File(ClassLoader.getSystemResource(cleanup).getFile()));
+				runSQLFiles(new File(sqlPath, cleanup));
 				
 				if (updatePath.exists()) {
 					final var sb = new StringBuilder();

+ 4 - 2
src/main/java/com/l2jserver/cli/dao/AccountDAO.java

@@ -18,7 +18,6 @@
  */
 package com.l2jserver.cli.dao;
 
-import static com.l2jserver.cli.config.Configs.loginServer;
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.security.MessageDigest;
@@ -26,11 +25,13 @@ import java.util.Base64;
 import java.util.HashMap;
 import java.util.Map;
 
+import com.l2jserver.cli.config.Configuration;
 import com.l2jserver.cli.model.AccountListType;
 
 /**
  * Account DAO.
  * @author Zoey76
+ * @version 1.0.0
  */
 public class AccountDAO extends AbstractDAO {
 	
@@ -50,7 +51,7 @@ public class AccountDAO extends AbstractDAO {
 	private static final String ALGORITHM = "SHA";
 	
 	private AccountDAO() {
-		super(loginServer().db().host(), loginServer().db().port(), loginServer().db().name(), loginServer().db().user(), loginServer().db().password());
+		super(Configuration.loginServer());
 	}
 	
 	public boolean upsert(String username, String password, int accessLevel) {
@@ -65,6 +66,7 @@ public class AccountDAO extends AbstractDAO {
 			return ps.executeUpdate() > 0;
 		} catch (Exception ex) {
 			System.out.println("There was error while creating/updating account " + username + "!");
+			ex.printStackTrace();
 		}
 		return false;
 	}

+ 4 - 3
src/main/java/com/l2jserver/cli/dao/GameServerDAO.java

@@ -18,16 +18,17 @@
  */
 package com.l2jserver.cli.dao;
 
-import static com.l2jserver.cli.config.Configs.loginServer;
-
 import java.math.BigInteger;
 import java.sql.SQLException;
 import java.util.HashSet;
 import java.util.Set;
 
+import com.l2jserver.cli.config.Configuration;
+
 /**
  * Game Server DAO.
  * @author Zoey76
+ * @version 1.0.0
  */
 public class GameServerDAO extends AbstractDAO {
 	
@@ -40,7 +41,7 @@ public class GameServerDAO extends AbstractDAO {
 	private static final String DELETE_ALL_SERVERS = "DELETE FROM gameservers";
 	
 	private GameServerDAO() {
-		super(loginServer().db().host(), loginServer().db().port(), loginServer().db().name(), loginServer().db().user(), loginServer().db().password());
+		super(Configuration.loginServer());
 	}
 	
 	public void unregister(int id) throws SQLException {

+ 4 - 3
src/main/java/com/l2jserver/cli/dao/GameServerDatabaseDAO.java

@@ -18,15 +18,16 @@
  */
 package com.l2jserver.cli.dao;
 
-import static com.l2jserver.cli.config.Configs.gameServer;
+import com.l2jserver.cli.config.Configuration;
 
 /**
  * Game Server Database DAO.
  * @author Zoey76
+ * @version 1.0.0
  */
 public class GameServerDatabaseDAO extends AbstractDatabaseDAO {
-	
+
 	public GameServerDatabaseDAO() {
-		super(gameServer().db().host(), gameServer().db().port(), gameServer().db().name(), gameServer().db().user(), gameServer().db().password());
+		super(Configuration.gameServer());
 	}
 }

+ 3 - 2
src/main/java/com/l2jserver/cli/dao/LoginServerDatabaseDAO.java

@@ -18,15 +18,16 @@
  */
 package com.l2jserver.cli.dao;
 
-import static com.l2jserver.cli.config.Configs.loginServer;
+import com.l2jserver.cli.config.Configuration;
 
 /**
  * Login Server Database DAO.
  * @author Zoey76
+ * @version 1.0.0
  */
 public class LoginServerDatabaseDAO extends AbstractDatabaseDAO {
 	
 	public LoginServerDatabaseDAO() {
-		super(loginServer().db().host(), loginServer().db().port(), loginServer().db().name(), loginServer().db().user(), loginServer().db().password());
+		super(Configuration.loginServer());
 	}
 }

+ 1 - 0
src/main/java/com/l2jserver/cli/model/AccountListType.java

@@ -21,6 +21,7 @@ package com.l2jserver.cli.model;
 /**
  * Account List type.
  * @author Zoey76
+ * @version 1.0.0
  */
 public enum AccountListType {
 	ALL,

+ 1 - 0
src/main/java/com/l2jserver/cli/model/CloneType.java

@@ -21,6 +21,7 @@ package com.l2jserver.cli.model;
 /**
  * Clone type.
  * @author Zoey76
+ * @version 1.0.0
  */
 public enum CloneType {
 	BOTH,

+ 1 - 0
src/main/java/com/l2jserver/cli/model/DatabaseInstallType.java

@@ -21,6 +21,7 @@ package com.l2jserver.cli.model;
 /**
  * Database Install type.
  * @author Zoey76
+ * @version 1.0.0
  */
 public enum DatabaseInstallType {
 	FULL,

+ 1 - 0
src/main/java/com/l2jserver/cli/model/ServerNames.java

@@ -24,6 +24,7 @@ import java.util.Map;
 /**
  * Server Names.
  * @author Zoey76
+ * @version 1.0.0
  */
 public class ServerNames {
 	

+ 1 - 0
src/main/java/com/l2jserver/cli/model/ServerType.java

@@ -21,6 +21,7 @@ package com.l2jserver.cli.model;
 /**
  * Server type.
  * @author Zoey76
+ * @version 1.0.0
  */
 public enum ServerType {
 	GAME,

+ 1 - 0
src/main/java/com/l2jserver/cli/util/FileWriterStdout.java

@@ -26,6 +26,7 @@ import java.io.IOException;
  * File writer.
  * @author mrTJO
  * @author Zoey76
+ * @version 1.0.0
  */
 public class FileWriterStdout extends BufferedWriter {
 	public FileWriterStdout(FileWriter fileWriter) {

+ 1 - 0
src/main/java/com/l2jserver/cli/util/LoggerProgressMonitor.java

@@ -24,6 +24,7 @@ import org.slf4j.Logger;
 /**
  * Logger progress monitor.
  * @author Zoey76
+ * @version 1.0.0
  */
 public class LoggerProgressMonitor extends BatchingProgressMonitor {
 	private final Logger log;

+ 1 - 0
src/main/java/com/l2jserver/cli/util/SQLFilter.java

@@ -25,6 +25,7 @@ import java.io.FileFilter;
  * Specialized {@link FileFilter} class.<br>
  * Accepts <b>files</b> ending with ".sql" only.
  * @author Zoey76
+ * @version 1.0.0
  */
 public class SQLFilter implements FileFilter {
 	@Override

+ 1 - 0
src/main/java/com/l2jserver/gui/editor/ConfigUserInterface.java

@@ -78,6 +78,7 @@ import com.l2jserver.gui.editor.ConfigUserInterface.ConfigFile.ConfigProperty;
  * Configuration Editor GUI.
  * @author KenM
  * @author Zoey76
+ * @version 1.0.0
  */
 public class ConfigUserInterface extends JFrame implements ActionListener {
 	private static final long serialVersionUID = 2609592249095305857L;

+ 2 - 0
src/main/java/com/l2jserver/gui/editor/JIPTextField.java

@@ -40,7 +40,9 @@ import javax.swing.text.BadLocationException;
 import javax.swing.text.PlainDocument;
 
 /**
+ * IP custom field.
  * @author KenM
+ * @version 1.0.0
  */
 public class JIPTextField extends JPanel implements FocusListener {
 	private static final long serialVersionUID = 1L;

+ 0 - 13
src/main/resources/config.properties

@@ -1,13 +0,0 @@
-# Game Server
-gs.db.name=l2jgs
-gs.db.host=127.0.0.1
-gs.db.port=3306
-gs.db.user=root
-gs.db.password=toor
-
-# Login Server
-ls.db.name=l2jls
-ls.db.host=127.0.0.1
-ls.db.port=3306
-ls.db.user=root
-ls.db.password=toor

+ 27 - 0
src/main/resources/config/game-server.properties

@@ -0,0 +1,27 @@
+# Database Driver
+# DatabaseDriver=com.mysql.cj.jdbc.Driver
+# DatabaseDriver=org.hsqldb.jdbcDriver
+# DatabaseDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver
+# DatabaseDriver=org.mariadb.jdbc.Driver
+DatabaseDriver=org.mariadb.jdbc.Driver
+# Database URL
+# DatabaseURL=jdbc:mysql://localhost/l2jgs?createDatabaseIfNotExist=true&allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC
+# DatabaseURL=jdbc:hsqldb:hsql://localhost/l2jgs
+# DatabaseURL=jdbc:sqlserver://localhost/database=l2jgs/user=sa/password=sa
+# DatabaseURL=jdbc:mariadb://localhost/l2jgs?createDatabaseIfNotExist=true
+DatabaseURL=jdbc:mariadb://localhost/l2jgs?createDatabaseIfNotExist=true
+# Database Name
+DatabaseName=l2jgs
+# Database User
+DatabaseUser=l2j
+# Database Password
+DatabasePassword=l2jserver2019
+# Connection Pool
+# DatabaseConnectionPool=BoneCP
+# DatabaseConnectionPool=C3P0
+# DatabaseConnectionPool=HikariCP
+DatabaseConnectionPool=HikariCP
+# Maximum Pool Size
+DatabaseMaximumPoolSize=100
+# Maximum Idle Time
+DatabaseMaximumIdleTime=0

+ 27 - 0
src/main/resources/config/login-server.properties

@@ -0,0 +1,27 @@
+# Database Driver
+# DatabaseDriver=com.mysql.cj.jdbc.Driver
+# DatabaseDriver=org.hsqldb.jdbcDriver
+# DatabaseDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver
+# DatabaseDriver=org.mariadb.jdbc.Driver
+DatabaseDriver=org.mariadb.jdbc.Driver
+# Database URL
+# DatabaseURL=jdbc:mysql://localhost/l2jls?createDatabaseIfNotExist=true&allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC
+# DatabaseURL=jdbc:hsqldb:hsql://localhost/l2jls
+# DatabaseURL=jdbc:sqlserver://localhost/database=l2jls/user=sa/password=sa
+# DatabaseURL=jdbc:mariadb://localhost/l2jls?createDatabaseIfNotExist=true
+DatabaseURL=jdbc:mariadb://localhost/l2jls?createDatabaseIfNotExist=true
+# Database Name
+DatabaseName=l2jls
+# Database User
+DatabaseUser=l2j
+# Database Password
+DatabasePassword=l2jserver2019
+# Connection Pool
+# DatabaseConnectionPool=BoneCP
+# DatabaseConnectionPool=C3P0
+# DatabaseConnectionPool=HikariCP
+DatabaseConnectionPool=HikariCP
+# Maximum Pool Size
+DatabaseMaximumPoolSize=100
+# Maximum Idle Time
+DatabaseMaximumIdleTime=0

+ 1 - 1
src/main/resources/log4j2.xml

@@ -6,7 +6,7 @@
 		</Console>
 	</Appenders>
 	<Loggers>
-		<Root level="debug" additivity="false">
+		<Root level="info" additivity="false">
 			<AppenderRef ref="console" />
 		</Root>
 	</Loggers>

+ 0 - 115
src/main/resources/sql/cleanup/gs_cleanup.sql

@@ -1,115 +0,0 @@
--- These queries are meant to delete any game server table you may have from previous L2J installations.
---
--- Queries that create these tables and/or populate them apropiately are available in L2J DataPack.
-
-DROP TABLE IF EXISTS 
-account_gsdata,
-airships,
-announcements,
-auction,
-auction_bid,
-auction_watch,
-bbs_favorites,
-bot_reported_char_data,
-buylists,
-castle,
-castle_doorupgrade,
-castle_functions,
-castle_manor_procure,
-castle_manor_production,
-castle_siege_guards,
-castle_trapupgrade,
-character_contacts,
-character_friends,
-character_hennas,
-character_instance_time,
-character_item_reuse_save,
-character_macroses,
-character_offline_trade,
-character_offline_trade_items,
-character_pet_skills_save,
-character_premium_items,
-character_quest_global_data,
-character_quests,
-character_raid_points,
-character_recipebook,
-character_recipeshoplist,
-character_reco_bonus,
-character_shortcuts,
-character_skills,
-character_skills_save,
-character_subclasses,
-character_summon_skills_save,
-character_summons,
-character_tpbookmark,
-character_ui_actions,
-character_ui_categories,
-character_variables,
-characters,
-clan_data,
-clan_notices,
-clan_privs,
-clan_skills,
-clan_subpledges,
-clan_wars,
-clanhall,
-clanhall_functions,
-clanhall_siege_attackers,
-clanhall_siege_guards,
-crests,
-cursed_weapons,
-dimensional_rift,
-fort,
-fort_doorupgrade,
-fort_functions,
-fort_siege_guards,
-fort_spawnlist,
-fortsiege_clans,
-forums,
-four_sepulchers_spawnlist,
-games,
-global_tasks,
-global_variables,
-grandboss_data,
-grandboss_list,
-herb_droplist_groups,
-heroes,
-heroes_diary,
-item_attributes,
-item_auction,
-item_auction_bid,
-item_elementals,
-items,
-itemsonground,
-locations,
-merchant_lease,
-messages,
-mods_wedding,
-npc_buffer,
-olympiad_data,
-olympiad_fights,
-olympiad_nobles,
-olympiad_nobles_eom,
-petition_feedback,
-pets,
-pets_skills,
-posts,
-punishments,
-quest_global_data,
-raidboss_spawnlist,
-rainbowsprings_attacker_list,
-random_spawn,
-random_spawn_loc,
-seven_signs,
-seven_signs_festival,
-seven_signs_status,
-siegable_clanhall,
-siegable_hall_flagwar_attackers,
-siegable_hall_flagwar_attackers_members,
-siege_clans,
-spawnlist,
-teleport,
-territories,
-territory_registrations,
-territory_spawnlist,
-topic;

+ 0 - 9
src/main/resources/sql/cleanup/ls_cleanup.sql

@@ -1,9 +0,0 @@
--- These queries are meant to delete any login server table you may have from previous L2J installations.
---
--- Queries that create these tables and/or populate them apropiately are available in L2J DataPack.
-
-DROP TABLE IF EXISTS
-account_data,
-accounts,
-accounts_ipauth,
-gameservers;