Search in sources :

Example 46 with DSLContext

use of org.jooq.DSLContext in project Skree by Skelril.

the class RegionManager method writeRemRegion.

private void writeRemRegion(Collection<RegionDatabaseHandle> oldRegions) {
    try (Connection con = SQLHandle.getConnection()) {
        DSLContext create = DSL.using(con);
        con.setAutoCommit(false);
        for (RegionDatabaseHandle region : oldRegions) {
            create.deleteFrom(REGIONS).where(REGIONS.UUID.equal(region.getID().toString())).execute();
        }
        con.commit();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) DSLContext(org.jooq.DSLContext)

Example 47 with DSLContext

use of org.jooq.DSLContext in project Skree by Skelril.

the class ServerSideWorldRegistar method register.

public void register(String name) {
    try (Connection con = SQLHandle.getConnection()) {
        DSLContext create = DSL.using(con);
        Timestamp createdTime = new Timestamp(System.currentTimeMillis());
        create.insertInto(WORLDS).columns(WORLDS.NAME, WORLDS.CREATED_AT).values(name, createdTime).onDuplicateKeyUpdate().set(WORLDS.CREATED_AT, createdTime).execute();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) DSLContext(org.jooq.DSLContext) Timestamp(java.sql.Timestamp)

Aggregations

DSLContext (org.jooq.DSLContext)47 Connection (java.sql.Connection)23 SQLException (java.sql.SQLException)17 Test (org.junit.Test)8 Timestamp (java.sql.Timestamp)6 ArrayList (java.util.ArrayList)5 Field (org.jooq.Field)5 Listener (org.spongepowered.api.event.Listener)4 MetricRegistry (com.codahale.metrics.MetricRegistry)3 JooqContainer (com.intel.mtwilson.jooq.util.JooqContainer)3 Record (org.jooq.Record)3 Settings (org.jooq.conf.Settings)3 Context (com.torodb.backend.ErrorHandler.Context)2 ResultSet (java.sql.ResultSet)2 List (java.util.List)2 UUID (java.util.UUID)2 DataSource (javax.sql.DataSource)2 Record1 (org.jooq.Record1)2 SelectQuery (org.jooq.SelectQuery)2 TableField (org.jooq.TableField)2