use of net.anweisen.utilities.database.exceptions.DatabaseException in project Utility by anweisen.
the class SQLCountEntries method execute.
@Nonnull
@Override
public Long execute() throws DatabaseException {
try {
PreparedStatement statement = database.prepare("SELECT COUNT(*) FROM `" + table + "`");
ResultSet result = statement.executeQuery();
if (!result.next()) {
result.close();
return 0L;
}
long count = result.getLong(1);
result.close();
return count;
} catch (Exception ex) {
throw new DatabaseException(ex);
}
}
use of net.anweisen.utilities.database.exceptions.DatabaseException in project Utility by anweisen.
the class SQLDeletion method execute.
@Override
public Void execute() throws DatabaseException {
try {
PreparedStatement statement = prepare();
statement.execute();
return null;
} catch (Exception ex) {
throw new DatabaseException(ex);
}
}
use of net.anweisen.utilities.database.exceptions.DatabaseException in project Utility by anweisen.
the class SQLInsertion method execute.
@Override
public Void execute() throws DatabaseException {
try {
PreparedStatement statement = prepare();
statement.execute();
return null;
} catch (Exception ex) {
throw new DatabaseException(ex);
}
}
use of net.anweisen.utilities.database.exceptions.DatabaseException in project Utility by anweisen.
the class SQLQuery method execute.
@Nonnull
@Override
public ExecutedQuery execute() throws DatabaseException {
try {
PreparedStatement statement = prepare();
ResultSet result = statement.executeQuery();
return createExecutedQuery(result);
} catch (Exception ex) {
throw new DatabaseException(ex);
}
}
use of net.anweisen.utilities.database.exceptions.DatabaseException in project Utility by anweisen.
the class MongoDBDatabase method createTable.
@Override
public void createTable(@Nonnull String name, @Nonnull SQLColumn... columns) throws DatabaseException {
checkConnection();
boolean collectionExists = listTables().execute().contains(name);
if (collectionExists)
return;
try {
database.createCollection(name);
} catch (Exception ex) {
throw new DatabaseException(ex);
}
}
Aggregations