<commit_before>package de.st_ddt.crazyutil.databases;

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

import org.bukkit.configuration.ConfigurationSection;

public class MySQLConnection
{

	private Connection connection = null;
	private final String host;
	private final String port;
	private final String database;
	private final String user;
	private final String password;

	public MySQLConnection(final ConfigurationSection config)
	{
		this(config, "localhost", "3306", "database", "root", "password");
	}

	public MySQLConnection(final ConfigurationSection config, final String defaultHost, final String defaultPort, final String defaultDatabase, final String defaultUser, final String defaultPassword)
	{
		this(config.getString("database.host", defaultHost), config.getString("database.port", defaultPort), config.getString("database.dbname", defaultDatabase), config.getString("database.user", defaultUser), config.getString("database.password", defaultPassword));
		config.set("database.host", host);
		config.set("database.port", port);
		config.set("database.dbname", database);
		config.set("database.user", user);
		config.set("database.password", password);
	}

	public MySQLConnection(final String host, final String port, final String database, final String user, final String password)
	{
		super();
		this.host = host;
		this.port = port;
		this.database = database;
		this.user = user;
		this.password = password;
		try
		{
			Class.forName("com.mysql.jdbc.Driver");
		}
		catch (final ClassNotFoundException e)
		{
			// TODO Download and retry
			System.err.println("JBDC-Treiber not found");
		}
		connect();<commit_msg>CrazyDatabase: save mysql connection data to config before using them<commit_after>package de.st_ddt.crazyutil.databases;

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

import org.bukkit.configuration.ConfigurationSection;

public class MySQLConnection
{

	private Connection connection = null;
	private final String host;
	private final String port;
	private final String database;
	private final String user;
	private final String password;

	public static MySQLConnection connect(final ConfigurationSection config)
	{
		return connect(config, "localhost", "3306", "database", "root", "password");
	}

	public static MySQLConnection connect(final ConfigurationSection config, final String defaultHost, final String defaultPort, final String defaultDatabase, final String defaultUser, final String defaultPassword)
	{
		final String host = config.getString("database.host", defaultHost);
		config.set("database.host", host);
		final String port = config.getString("database.port", defaultPort);
		config.set("database.port", port);
		final String database = config.getString("database.dbname", defaultDatabase);
		config.set("database.dbname", database);
		final String user = config.getString("database.user", defaultUser);
		config.set("database.user", user);
		final String password = config.getString("database.password", defaultPassword);
		config.set("database.password", password);
		return new MySQLConnection(host, port, database, user, password);
	}

	public MySQLConnection(final String host, final String port, final String database, final String user, final String password)
	{
		super();
		this.host = host;
		this.port = port;
		this.database = database;
		this.user = user;
		this.password = password;
		try
		{
			Class.forName("com.mysql.jdbc.Driver");
		}
		catch (final ClassNotFoundException e)
		{
			// TODO Download and retry
			System.err.println("JBDC-Treiber not found");
		}
		connect();
{'fraction_non_alphanumeric': 0.10943499725726824, 'fraction_numerical': 0.0021941854086670325, 'mean_word_length': 5.398245614035088, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3517855', 'n_tokens_mistral': 1059, 'n_tokens_neox': 974, 'n_words': 289}