Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. import java.sql.DriverManager;
  2. import java.sql.ResultSet;
  3. import java.sql.Connection;
  4. import java.sql.SQLException;
  5.  
  6. import com.mysql.jdbc.Statement;
  7.  
  8. public class vote {
  9.  
  10. public static void checkAuth(String authCode) throws SQLException {
  11. try {
  12. Class.forName("com.mysql.jdbc.Driver");
  13. } catch (ClassNotFoundException e) {
  14. System.out.println("Where is your MySQL JDBC Driver?");
  15. e.printStackTrace();
  16. return;
  17. }
  18. Connection connection = null;
  19. Statement stmt = null;
  20.  
  21. try {
  22. connection = DriverManager
  23. .getConnection("jdbc:mysql://cpanel.blazingfast.io:3306/elveron_voting","elveron_voting", "elveronvoting");
  24.  
  25. } catch (SQLException e) {
  26. System.out.println("Connection Failed! Check output console");
  27. e.printStackTrace();
  28. return;
  29. }
  30.  
  31. if (connection != null) {
  32. stmt = (Statement) connection.createStatement();
  33. String sql;
  34. sql = "SELECT id FROM claim WHERE status='" +authCode+ "'";
  35. ResultSet rs = stmt.executeQuery(sql);
  36. while(rs.next()){
  37. int id = rs.getInt("id");
  38. switch(id) {
  39. case 1:
  40. //give 500k gold
  41. break;
  42. case 2:
  43. //20k ecto tokens
  44. break;
  45. case 3:
  46. //15 spins
  47. break;
  48. case 4:
  49. //100 vote points
  50. break;
  51. case 5:
  52. //mystery box
  53. break;
  54. case 6:
  55. //prized pendant
  56. break;
  57. }
  58. }
  59. sql = "DELETE FROM claim WHERE status='" +authCode+ "'";
  60. stmt.execute(sql);
  61. rs.close();
  62. stmt.close();
  63. connection.close();
  64.  
  65. } else {
  66. System.out.println("Failed to make connection!");
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement