org.spongepowered.api.service.sql.SqlService Java Examples

The following examples show how to use org.spongepowered.api.service.sql.SqlService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VirtualChestRecordManager.java    From VirtualChest with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void init()
{
    this.sql = Sponge.getServiceManager().provideUnchecked(SqlService.class);
    try // TODO: the logger is annoying, so disable it anyway (although it is a dirty way)
    {
        Field field = DB.class.getDeclaredField("LOGGER");
        field.setAccessible(true);

        Field modifiersField = Field.class.getDeclaredField("modifiers");
        int m = field.getModifiers() & ~Modifier.FINAL;
        modifiersField.setAccessible(true);
        modifiersField.setInt(field, m);

        NOPLogger l = NOPLogger.NOP_LOGGER;
        field.set(null, l);
    }
    catch (ReflectiveOperationException e)
    {
        throw new IllegalStateException(e);
    }
}
 
Example #2
Source File: Database.java    From FlexibleLogin with MIT License 5 votes vote down vote up
public Database(Logger logger, Settings settings, String tableName) throws SQLException {
    this.logger = logger;
    this.tableName = tableName;

    SQLConfig sqlConfig = settings.getGeneral().getSQL();
    Path configDir = settings.getConfigDir();
    this.storageType = sqlConfig.getType();

    String jdbcConnection = buildJDBCUrl(sqlConfig, configDir);
    this.dataSource = Sponge.getServiceManager().provideUnchecked(SqlService.class).getDataSource(jdbcConnection);
}
 
Example #3
Source File: PlotMe_Sponge.java    From PlotMe-Core with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
public void onInit(PreInitializationEvent event) {
    sql = services.potentiallyProvide(SqlService.class);
    configDir.mkdirs();
    load();
}