Search in sources :

Example 1 with H2ConnectionFactory

use of com.alessiodp.core.common.storage.sql.connection.H2ConnectionFactory in project ADP-Core by AlessioDP.

the class MigratorTest method getConnectionFactoryH2.

public static ConnectionFactory getConnectionFactoryH2() {
    // Note: This method is used by other test classes
    H2ConnectionFactory ret = new H2ConnectionFactory(mockPlugin, "jdbc:h2:mem:" + UUID.randomUUID() + ";DB_CLOSE_DELAY=-1");
    ret.setTablePrefix("test_");
    ret.init();
    return ret;
}
Also used : H2ConnectionFactory(com.alessiodp.core.common.storage.sql.connection.H2ConnectionFactory)

Example 2 with H2ConnectionFactory

use of com.alessiodp.core.common.storage.sql.connection.H2ConnectionFactory in project Parties by AlessioDP.

the class PartiesSQLDispatcher method initConnectionFactory.

@Override
public ConnectionFactory initConnectionFactory() {
    ConnectionFactory ret = null;
    switch(storageType) {
        case MARIADB:
            ret = new MariaDBConnectionFactory();
            ((MariaDBConnectionFactory) ret).setTablePrefix(ConfigMain.STORAGE_SETTINGS_GENERAL_SQL_PREFIX);
            ((MariaDBConnectionFactory) ret).setCharset(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_CHARSET);
            ((MariaDBConnectionFactory) ret).setServerName(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_ADDRESS);
            ((MariaDBConnectionFactory) ret).setPort(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_PORT);
            ((MariaDBConnectionFactory) ret).setDatabaseName(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_DATABASE);
            ((MariaDBConnectionFactory) ret).setUsername(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_USERNAME);
            ((MariaDBConnectionFactory) ret).setPassword(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_PASSWORD);
            ((MariaDBConnectionFactory) ret).setMaximumPoolSize(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_POOLSIZE);
            ((MariaDBConnectionFactory) ret).setMaxLifetime(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_CONNLIFETIME);
            ((MariaDBConnectionFactory) ret).setAdditionalParameters(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_ADDITIONAL_PARAMETERS);
            break;
        case MYSQL:
            ret = new MySQLConnectionFactory();
            ((MySQLConnectionFactory) ret).setTablePrefix(ConfigMain.STORAGE_SETTINGS_GENERAL_SQL_PREFIX);
            ((MySQLConnectionFactory) ret).setCharset(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_CHARSET);
            ((MySQLConnectionFactory) ret).setServerName(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_ADDRESS);
            ((MySQLConnectionFactory) ret).setPort(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_PORT);
            ((MySQLConnectionFactory) ret).setDatabaseName(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_DATABASE);
            ((MySQLConnectionFactory) ret).setUsername(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_USERNAME);
            ((MySQLConnectionFactory) ret).setPassword(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_PASSWORD);
            ((MySQLConnectionFactory) ret).setMaximumPoolSize(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_POOLSIZE);
            ((MySQLConnectionFactory) ret).setMaxLifetime(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_CONNLIFETIME);
            ((MySQLConnectionFactory) ret).setUseSSL(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_USESSL);
            ((MySQLConnectionFactory) ret).setAdditionalParameters(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_ADDITIONAL_PARAMETERS);
            break;
        case POSTGRESQL:
            ret = new PostgreSQLConnectionFactory();
            ((PostgreSQLConnectionFactory) ret).setTablePrefix(ConfigMain.STORAGE_SETTINGS_GENERAL_SQL_PREFIX);
            ((PostgreSQLConnectionFactory) ret).setCharset(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_CHARSET);
            ((PostgreSQLConnectionFactory) ret).setServerName(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_ADDRESS);
            ((PostgreSQLConnectionFactory) ret).setPort(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_PORT);
            ((PostgreSQLConnectionFactory) ret).setDatabaseName(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_DATABASE);
            ((PostgreSQLConnectionFactory) ret).setUsername(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_USERNAME);
            ((PostgreSQLConnectionFactory) ret).setPassword(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_PASSWORD);
            ((PostgreSQLConnectionFactory) ret).setMaximumPoolSize(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_POOLSIZE);
            ((PostgreSQLConnectionFactory) ret).setMaxLifetime(ConfigMain.STORAGE_SETTINGS_REMOTE_SQL_CONNLIFETIME);
            playersDao = PostgreSQLPlayersDao.class;
            partiesDao = PostgreSQLPartiesDao.class;
            break;
        case SQLITE:
            ret = new SQLiteConnectionFactory(plugin, plugin.getFolder().resolve(ConfigMain.STORAGE_SETTINGS_SQLITE_DBFILE));
            ((SQLiteConnectionFactory) ret).setTablePrefix(ConfigMain.STORAGE_SETTINGS_GENERAL_SQL_PREFIX);
            playersDao = SQLitePlayersDao.class;
            partiesDao = SQLitePartiesDao.class;
            break;
        case H2:
            ret = new H2ConnectionFactory(plugin, plugin.getFolder().resolve(ConfigMain.STORAGE_SETTINGS_H2_DBFILE));
            ((H2ConnectionFactory) ret).setTablePrefix(ConfigMain.STORAGE_SETTINGS_GENERAL_SQL_PREFIX);
            playersDao = H2PlayersDao.class;
            partiesDao = H2PartiesDao.class;
            break;
        default:
    }
    return ret;
}
Also used : MySQLConnectionFactory(com.alessiodp.core.common.storage.sql.connection.MySQLConnectionFactory) PostgreSQLConnectionFactory(com.alessiodp.core.common.storage.sql.connection.PostgreSQLConnectionFactory) H2ConnectionFactory(com.alessiodp.core.common.storage.sql.connection.H2ConnectionFactory) ConnectionFactory(com.alessiodp.core.common.storage.sql.connection.ConnectionFactory) MariaDBConnectionFactory(com.alessiodp.core.common.storage.sql.connection.MariaDBConnectionFactory) SQLiteConnectionFactory(com.alessiodp.core.common.storage.sql.connection.SQLiteConnectionFactory) MariaDBConnectionFactory(com.alessiodp.core.common.storage.sql.connection.MariaDBConnectionFactory) PostgreSQLConnectionFactory(com.alessiodp.core.common.storage.sql.connection.PostgreSQLConnectionFactory) H2ConnectionFactory(com.alessiodp.core.common.storage.sql.connection.H2ConnectionFactory) MySQLConnectionFactory(com.alessiodp.core.common.storage.sql.connection.MySQLConnectionFactory) SQLiteConnectionFactory(com.alessiodp.core.common.storage.sql.connection.SQLiteConnectionFactory)

Aggregations

H2ConnectionFactory (com.alessiodp.core.common.storage.sql.connection.H2ConnectionFactory)2 ConnectionFactory (com.alessiodp.core.common.storage.sql.connection.ConnectionFactory)1 MariaDBConnectionFactory (com.alessiodp.core.common.storage.sql.connection.MariaDBConnectionFactory)1 MySQLConnectionFactory (com.alessiodp.core.common.storage.sql.connection.MySQLConnectionFactory)1 PostgreSQLConnectionFactory (com.alessiodp.core.common.storage.sql.connection.PostgreSQLConnectionFactory)1 SQLiteConnectionFactory (com.alessiodp.core.common.storage.sql.connection.SQLiteConnectionFactory)1