Updated the consumer methods in the MySQLConnection

This commit is contained in:
mathias 2021-08-20 14:53:12 +02:00
parent b28b2606cb
commit fefbebeb3a
No known key found for this signature in database
GPG Key ID: 8950DF62139C852A

View File

@ -99,12 +99,26 @@ public class MySQLConnection {
* @param consumer The consumer * @param consumer The consumer
* @param params The optional parameters * @param params The optional parameters
*/ */
public void getResult(String query, SQLConsumer<ResultSet> consumer, Object... params) { public void getResultSet(String query, SQLConsumer<ResultSet> consumer, Object... params) {
try { try {
ResultSet resultSet = getResultSet(query, params); consumer.accept(getResultSet(query, params));
consumer.accept(resultSet); } catch (Exception e) {
resultSet.close(); LOG.error(e.getMessage());
} catch (Exception ignored) { }
}
/**
* Run an action with a result from your server
*
* @param query The search query
* @param consumer The consumer
* @param params The optional parameters
*/
public void getResult(String query, SQLConsumer<ResultManager> consumer, Object... params) {
try {
consumer.accept(getResult(query, params));
} catch (Exception e) {
LOG.error(e.getMessage());
} }
} }