Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. package me.tintaverificar.mysql;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.PreparedStatement;
  6. import java.sql.ResultSet;
  7. import java.sql.SQLException;
  8. import java.util.Calendar;
  9. import java.util.Date;
  10. import java.util.concurrent.ConcurrentHashMap;
  11.  
  12. import org.bukkit.scheduler.BukkitRunnable;
  13.  
  14. import me.tintaverificar.Main;
  15.  
  16. public class MySQL {
  17. private String user;
  18. private String password;
  19. private String database;
  20. private String host;
  21. private int servidor;
  22. private Connection connection;
  23.  
  24. public MySQL(final String user, final String password, final String database, final String host,
  25. final int servidor) {
  26. this.user = user;
  27. this.password = password;
  28. this.database = database;
  29. this.host = host;
  30. this.servidor = servidor;
  31. this.setConnection();
  32. }
  33.  
  34. private void setConnection() {
  35. try {
  36. Class.forName("com.mysql.jdbc.Driver");
  37. this.connection = DriverManager.getConnection(
  38. "jdbc:mysql://" + this.host + "/" + this.database + "?autoReconnect=true", this.user,
  39. this.password);
  40. } catch (ClassNotFoundException e) {
  41. e.printStackTrace();
  42. } catch (SQLException e2) {
  43. e2.printStackTrace();
  44. }
  45. }
  46.  
  47. public ConcurrentHashMap<Integer, String> get() {
  48. try {
  49. final PreparedStatement stmt = this.connection.prepareStatement("SELECT * FROM website_transactions");
  50. final ResultSet rs = stmt.executeQuery();
  51. final ConcurrentHashMap<Integer, String> query = new ConcurrentHashMap<Integer, String>();
  52. while (rs.next()) {
  53. boolean ativado = rs.getBoolean("transaction_ACTIVE");
  54. }
  55. return query;
  56. } catch (SQLException ex) {
  57. ex.printStackTrace();
  58. return null;
  59. }
  60. }
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement