mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-27 02:21:30 +01:00
Implemented Database#query in SQLDB, deprecated old access methods
This commit is contained in:
parent
3c66ca3331
commit
a9e5524775
@ -20,6 +20,7 @@ import com.djrapitops.plan.api.exceptions.database.DBInitException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.data.store.containers.NetworkContainer;
|
||||
import com.djrapitops.plan.db.access.ExecStatement;
|
||||
import com.djrapitops.plan.db.access.Query;
|
||||
import com.djrapitops.plan.db.access.QueryStatement;
|
||||
import com.djrapitops.plan.db.patches.*;
|
||||
import com.djrapitops.plan.db.sql.tables.*;
|
||||
@ -317,6 +318,7 @@ public abstract class SQLDB extends AbstractDatabase {
|
||||
|
||||
public abstract void returnToPool(Connection connection);
|
||||
|
||||
@Deprecated
|
||||
public boolean execute(ExecStatement statement) {
|
||||
if (!isOpen()) {
|
||||
throw new DBOpException("SQL Statement tried to execute while connection closed");
|
||||
@ -335,6 +337,7 @@ public abstract class SQLDB extends AbstractDatabase {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean execute(String sql) {
|
||||
return execute(new ExecStatement(sql) {
|
||||
@Override
|
||||
@ -344,6 +347,7 @@ public abstract class SQLDB extends AbstractDatabase {
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void executeUnsafe(String... statements) {
|
||||
Verify.nullCheck(statements);
|
||||
for (String statement : statements) {
|
||||
@ -357,6 +361,7 @@ public abstract class SQLDB extends AbstractDatabase {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void executeBatch(ExecStatement statement) {
|
||||
if (!isOpen()) {
|
||||
throw new DBOpException("SQL Batch tried to execute while connection closed");
|
||||
@ -375,6 +380,7 @@ public abstract class SQLDB extends AbstractDatabase {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public <T> T query(QueryStatement<T> statement) {
|
||||
if (!isOpen()) {
|
||||
throw new DBOpException("SQL Query tried to execute while connection closed");
|
||||
@ -393,6 +399,11 @@ public abstract class SQLDB extends AbstractDatabase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T query(Query<T> query) {
|
||||
return query.executeQuery(this);
|
||||
}
|
||||
|
||||
public UsersTable getUsersTable() {
|
||||
return usersTable;
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ import com.djrapitops.plan.db.SQLDB;
|
||||
*/
|
||||
public interface Query<T> {
|
||||
|
||||
T query(SQLDB db);
|
||||
T executeQuery(SQLDB db);
|
||||
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public abstract class QueryStatement<T> implements Query<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T query(SQLDB db) {
|
||||
public T executeQuery(SQLDB db) {
|
||||
Connection connection = null;
|
||||
try {
|
||||
connection = db.getConnection();
|
||||
|
Loading…
Reference in New Issue
Block a user