Search in sources :

Example 6 with ExecStatement

use of com.djrapitops.plan.storage.database.transactions.ExecStatement in project Plan by plan-player-analytics.

the class KickStoreTransaction method performOperations.

@Override
protected void performOperations() {
    String sql = "UPDATE " + UsersTable.TABLE_NAME + " SET " + UsersTable.TIMES_KICKED + "=" + UsersTable.TIMES_KICKED + "+ 1" + WHERE + UsersTable.USER_UUID + "=?";
    execute(new ExecStatement(sql) {

        @Override
        public void prepare(PreparedStatement statement) throws SQLException {
            statement.setString(1, playerUUID.toString());
        }
    });
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) ExecStatement(com.djrapitops.plan.storage.database.transactions.ExecStatement)

Example 7 with ExecStatement

use of com.djrapitops.plan.storage.database.transactions.ExecStatement in project Plan by plan-player-analytics.

the class ServerIsProxyPatch method applyPatch.

@Override
protected void applyPatch() {
    addColumn(ServerTable.TABLE_NAME, ServerTable.PROXY + ' ' + Sql.BOOL + " DEFAULT 0");
    String populateFieldSql = "UPDATE " + ServerTable.TABLE_NAME + " SET " + ServerTable.PROXY + "=?" + WHERE + ServerTable.NAME + "=?";
    execute(new ExecStatement(populateFieldSql) {

        @Override
        public void prepare(PreparedStatement statement) throws SQLException {
            statement.setBoolean(1, true);
            statement.setString(2, "BungeeCord");
        }
    });
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) ExecStatement(com.djrapitops.plan.storage.database.transactions.ExecStatement)

Example 8 with ExecStatement

use of com.djrapitops.plan.storage.database.transactions.ExecStatement in project Plan by plan-player-analytics.

the class UserInfoHostnameAllowNullPatch method applyPatch.

@Override
protected void applyPatch() {
    tempOldTable();
    execute(UserInfoTable.createTableSQL(dbType));
    execute(new ExecStatement("INSERT INTO " + TABLE_NAME + " (" + UserInfoTable.ID + ',' + UserInfoTable.USER_ID + ',' + UserInfoTable.SERVER_ID + ',' + UserInfoTable.REGISTERED + ',' + UserInfoTable.OP + ',' + UserInfoTable.BANNED + ',' + UserInfoTable.JOIN_ADDRESS + ") SELECT " + UserInfoTable.ID + ',' + UserInfoTable.USER_ID + ',' + UserInfoTable.SERVER_ID + ',' + UserInfoTable.REGISTERED + ',' + UserInfoTable.OP + ',' + UserInfoTable.BANNED + ',' + "?" + FROM + TEMP_TABLE_NAME) {

        @Override
        public void prepare(PreparedStatement statement) throws SQLException {
            statement.setNull(1, Types.VARCHAR);
        }
    });
    dropTable(TEMP_TABLE_NAME);
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) ExecStatement(com.djrapitops.plan.storage.database.transactions.ExecStatement)

Example 9 with ExecStatement

use of com.djrapitops.plan.storage.database.transactions.ExecStatement in project Plan by plan-player-analytics.

the class BadNukkitRegisterValuePatch method multiplyInTable.

private void multiplyInTable(String tableName, String registered) {
    String sql = "UPDATE " + tableName + " SET " + registered + "=" + registered + "*1000" + WHERE + registered + "<?" + AND + registered + ">?";
    execute(new ExecStatement(sql) {

        @Override
        public void prepare(PreparedStatement statement) throws SQLException {
            statement.setLong(1, System.currentTimeMillis() / 1000L);
            statement.setLong(2, 0L);
        }
    });
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) ExecStatement(com.djrapitops.plan.storage.database.transactions.ExecStatement)

Example 10 with ExecStatement

use of com.djrapitops.plan.storage.database.transactions.ExecStatement in project Plan by plan-player-analytics.

the class StorePlayerTableResultTransaction method deleteOldRows.

private void deleteOldRows(Integer tableID, int afterRow) {
    String sql = DELETE_FROM + TABLE_NAME + WHERE + TABLE_ID + "=?" + AND + USER_UUID + "=?" + AND + TABLE_ROW + // Since row count is zero indexed and afterRow is size the value should be removed.
    ">=?";
    execute(new ExecStatement(sql) {

        @Override
        public void prepare(PreparedStatement statement) throws SQLException {
            statement.setInt(1, tableID);
            statement.setString(2, playerUUID.toString());
            statement.setInt(3, afterRow);
        }
    });
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) ExecStatement(com.djrapitops.plan.storage.database.transactions.ExecStatement)

Aggregations

ExecStatement (com.djrapitops.plan.storage.database.transactions.ExecStatement)11 PreparedStatement (java.sql.PreparedStatement)11 SQLException (java.sql.SQLException)10 StoreServerInformationTransaction (com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction)1 Transaction (com.djrapitops.plan.storage.database.transactions.Transaction)1 RemoveEverythingTransaction (com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction)1 RepeatedTest (org.junit.jupiter.api.RepeatedTest)1 Test (org.junit.jupiter.api.Test)1