use of at.xirado.bean.data.database.SQLBuilder in project Bean by Xirado.
the class GuildManager method retrieveGuildData.
private static GuildData retrieveGuildData(long guildID) {
String sql = "SELECT data FROM guildSettings WHERE guildID = ?";
var query = new SQLBuilder(sql).addParameter(guildID);
try (var rs = query.executeQuery()) {
if (rs.next())
return new GuildData(guildID, DataObject.fromJson(rs.getString("data")));
return null;
} catch (SQLException ex) {
LOGGER.error("Could not retrieve guild data!", ex);
return null;
}
}
use of at.xirado.bean.data.database.SQLBuilder in project Bean by Xirado.
the class GuildManager method updateGuildData.
private static void updateGuildData(long guildID, DataObject data) {
String sql = "INSERT INTO guildSettings (guildID, data) values (?,?) ON DUPLICATE KEY UPDATE data = ?";
try {
String jsonString = data.toString();
var query = new SQLBuilder(sql).addParameters(guildID, jsonString, jsonString);
query.execute();
} catch (SQLException exception) {
LOGGER.error("Could not update guild data!", exception);
}
}
Aggregations