Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1.  
  2.  
  3. public static boolean isUserexists(UUID uuid) {
  4. try{
  5. PreparedStatement ps = MySQL.getConnection.prepareStatement("SELECT gadgets FROM lobby WHERE UUID = ?");
  6. ps.getString(1, uuid.toString());
  7. ResultSet rs = ps.executeQuery();
  8. return rs.next();
  9. } catch (SQLException e){
  10. e.printStackTrace();
  11. }
  12. return false;
  13. }
  14.  
  15. public static void updateEnder(UUID uuid, int statusneu){
  16. if(isUserexists(uuid)) {
  17. int status = getStatusEnder(uuid);
  18. status=statusneu;
  19.  
  20. }else {
  21. try {
  22. PreparedStatement ps = MySQL.getConnection.prepareStatement("INSERT INTO lobby (UUID,STATUS) VALUES (?,?");
  23. ps.setString(1, uuid.toString());
  24. ps.setInt(2, 0);
  25. ps.executeUpdate();
  26.  
  27. } catch (SQLException e){
  28. e.printStackTrace();
  29. }
  30.  
  31. public static void updateEnterhaken(UUID uuid, int statusneu){
  32. if(isUserexists(uuid)) {
  33. try {
  34. int status = getStatusEnterhaken(uuid);
  35. status=statusneu;
  36.  
  37. PreparedStatement ps = MySQL.getConnection.prepareStatement("UPDATE lobby SET Enterhaken = ? WHERE UUID = ?);
  38. ps.setString(1, uuid.toString());
  39. ps.setInt(2, status);
  40. ps.executeUpdate();
  41.  
  42. } catch (SQLException e){
  43. e.printStackTrace();
  44. }
  45.  
  46. }else {
  47.  
  48. try {
  49. PreparedStatement ps = MySQL.getConnection.prepareStatement("INSERT INTO lobby (UUID,STATUS) VALUES (?,?");
  50. ps.setString(1, uuid.toString());
  51. ps.setInt(2, 0);
  52. ps.executeUpdate();
  53.  
  54. } catch (SQLException e){
  55. e.printStackTrace();
  56. }
  57.  
  58. public static Integer getStatusEnder(UUID uuid) {
  59. try{
  60. PreparedStatement ps = MySQL.getConnection.prepareStatement("SELECT gadgets FROM lobby WHERE UUID = ?");
  61. ps.getString(1, uuid.toString());
  62. ResultSet rs = ps.executeQuery();
  63. while(rs.next()) {
  64. return rs.getInt("ENDERPERLE");
  65. }
  66. } catch (SQLException e){
  67. e.printStackTrace();
  68. }
  69. return -1;
  70. }
  71.  
  72. public static Integer getStatusEnterhaken(UUID uuid) {
  73. try{
  74. PreparedStatement ps = MySQL.getConnection.prepareStatement("SELECT gadgets FROM lobby WHERE UUID = ?");
  75. ps.getString(1, uuid.toString());
  76. ResultSet rs = ps.executeQuery();
  77. while(rs.next()) {
  78. return rs.getInt("Enterhaken");
  79. }
  80. } catch (SQLException e){
  81. e.printStackTrace();
  82. }
  83. return -1;
  84. }
  85.  
  86.  
  87.  
  88.  
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement