use of util.Connexion in project KaellyBot by Kaysoro.
the class Guild method setLanguage.
public synchronized void setLanguage(Language lang) {
this.language = lang;
Connexion connexion = Connexion.getInstance();
Connection connection = connexion.getConnection();
try {
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE Guild SET lang = ? WHERE id = ?;");
preparedStatement.setString(1, lang.getAbrev());
preparedStatement.setString(2, id);
preparedStatement.executeUpdate();
} catch (SQLException e) {
Reporter.report(e);
LOG.error(e.getMessage());
}
}
use of util.Connexion in project KaellyBot by Kaysoro.
the class Guild method setName.
public synchronized void setName(String name) {
this.name = name;
Connexion connexion = Connexion.getInstance();
Connection connection = connexion.getConnection();
try {
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE Guild SET name = ? WHERE id = ?;");
preparedStatement.setString(1, name);
preparedStatement.setString(2, id);
preparedStatement.executeUpdate();
} catch (SQLException e) {
Reporter.report(e);
LOG.error(e.getMessage());
}
}
use of util.Connexion in project KaellyBot by Kaysoro.
the class OrderUser method addToDatabase.
/**
* Ajoute à la base de donnée l'objet si celui-ci n'y est pas déjà.
*/
public synchronized void addToDatabase() {
if (!getOrders().containsKey(Quadruple.of(idUser, server, city, order)) && level > 0) {
getOrders().put(Quadruple.of(idUser, server, city, order), this);
Connexion connexion = Connexion.getInstance();
Connection connection = connexion.getConnection();
try {
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO Order_User(id_user, server_dofus, name_city, name_order, level) " + "VALUES(?, ?, ?, ?, ?);");
preparedStatement.setString(1, String.valueOf(idUser));
preparedStatement.setString(2, server.getName());
preparedStatement.setString(3, city.getName());
preparedStatement.setString(4, order.getName());
preparedStatement.setInt(5, level);
preparedStatement.executeUpdate();
} catch (SQLException e) {
Reporter.report(e, ClientConfig.DISCORD().getUserByID(idUser));
LOG.error("addToDatabase", e);
}
}
}
use of util.Connexion in project KaellyBot by Kaysoro.
the class OrderUser method setLevel.
public synchronized void setLevel(int level) {
if (level > 100)
level = 100;
this.level = level;
Connexion connexion = Connexion.getInstance();
Connection connection = connexion.getConnection();
try {
PreparedStatement preparedStatement;
if (level > 0) {
preparedStatement = connection.prepareStatement("UPDATE Order_User SET level = ?" + "WHERE name_city = ? AND name_order = ? AND id_user = ? AND server_dofus = ?;");
preparedStatement.setInt(1, level);
preparedStatement.setString(2, city.getName());
preparedStatement.setString(3, order.getName());
preparedStatement.setString(4, String.valueOf(idUser));
preparedStatement.setString(5, server.getName());
} else {
preparedStatement = connection.prepareStatement("DELETE FROM Order_User " + "WHERE name_city = ? AND name_order = ? AND id_user = ? AND server_dofus = ?;");
preparedStatement.setString(1, city.getName());
preparedStatement.setString(2, order.getName());
preparedStatement.setString(3, String.valueOf(idUser));
preparedStatement.setString(4, server.getName());
}
preparedStatement.executeUpdate();
} catch (SQLException e) {
Reporter.report(e, ClientConfig.DISCORD().getUserByID(idUser));
LOG.error("setLevel", e);
}
}
use of util.Connexion in project KaellyBot by Kaysoro.
the class ChannelLanguage method addToDatabase.
public synchronized void addToDatabase() {
if (!getChannelLanguages().containsKey(getChannelId())) {
getChannelLanguages().put(getChannelId(), this);
Connexion connexion = Connexion.getInstance();
Connection connection = connexion.getConnection();
try {
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO Channel_Language(id_chan, lang) VALUES(?, ?);");
preparedStatement.setString(1, String.valueOf(getChannelId()));
preparedStatement.setString(2, getLang().getAbrev());
preparedStatement.executeUpdate();
} catch (SQLException e) {
Reporter.report(e, ClientConfig.DISCORD().getChannelByID(getChannelId()).getGuild(), ClientConfig.DISCORD().getChannelByID(getChannelId()));
LOG.error("addToDatabase", e);
}
}
}
Aggregations