Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public final boolean hasAcccount(final UUID uuid) {
- checkConnectAndReconnectIfWant();
- try {
- final PreparedStatement ps = this.connection
- .prepareStatement("SELECT Uuid FROM `EVENT__players` WHERE Uuid = ?");
- ps.setString(1, uuid.toString());
- final ResultSet result = ps.executeQuery();
- final boolean hasAccount = result.next();
- ps.close();
- return hasAccount;
- } catch (final SQLException e) {
- System.out.println("Erreur lors de la tentative de verification de l'existance du compte dans la bdd : "
- + e.getMessage());
- e.printStackTrace();
- return false;
- }
- }
- private final void checkConnectAndReconnectIfWant() {
- if (!isConnect())
- connect();
- }
- private final void connect() {
- try {
- this.connection = DriverManager.getConnection(
- "jdbc:mysql://" + this.host + "/" + this.bddName + "?autoReconnect=true", this.userName,
- this.password);
- } catch (final SQLException e) {
- System.out.println("Erreur lors de la tentative de connection à la bdd: " + e.getMessage());
- }
- }
- private final boolean isConnect() {
- try {
- return this.connection != null && !this.connection.isClosed();
- } catch (SQLException e) {
- e.printStackTrace();
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement