Advertisement
Guest User

Untitled

a guest
Aug 5th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public final boolean hasAcccount(final UUID uuid) {
  2. checkConnectAndReconnectIfWant();
  3. try {
  4. final PreparedStatement ps = this.connection
  5. .prepareStatement("SELECT Uuid FROM `EVENT__players` WHERE Uuid = ?");
  6. ps.setString(1, uuid.toString());
  7. final ResultSet result = ps.executeQuery();
  8. final boolean hasAccount = result.next();
  9. ps.close();
  10. return hasAccount;
  11. } catch (final SQLException e) {
  12. System.out.println("Erreur lors de la tentative de verification de l'existance du compte dans la bdd : "
  13. + e.getMessage());
  14. e.printStackTrace();
  15. return false;
  16. }
  17. }
  18.  
  19.  
  20. private final void checkConnectAndReconnectIfWant() {
  21. if (!isConnect())
  22. connect();
  23. }
  24.  
  25. private final void connect() {
  26. try {
  27. this.connection = DriverManager.getConnection(
  28. "jdbc:mysql://" + this.host + "/" + this.bddName + "?autoReconnect=true", this.userName,
  29. this.password);
  30. } catch (final SQLException e) {
  31. System.out.println("Erreur lors de la tentative de connection à la bdd: " + e.getMessage());
  32. }
  33. }
  34.  
  35. private final boolean isConnect() {
  36. try {
  37. return this.connection != null && !this.connection.isClosed();
  38. } catch (SQLException e) {
  39. e.printStackTrace();
  40. return false;
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement