Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. package com.dark.core.network.mysql;
  2.  
  3.  
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6. import java.sql.Connection;
  7. import java.sql.SQLException;
  8.  
  9. import com.dark.rs2.entity.item.Item;
  10. import com.dark.rs2.entity.player.Player;
  11. import com.mysql.jdbc.Statement;
  12.  
  13. public class Donation {
  14.  
  15.  
  16. public static final String checkDonation = null;
  17.  
  18. public static void checkDonation(String username, Player player) throws SQLException {
  19. try {
  20. Class.forName("com.mysql.jdbc.Driver");
  21. } catch (ClassNotFoundException e) {
  22. System.out.println("Where is your MySQL JDBC Driver?");
  23. e.printStackTrace();
  24. return;
  25. }
  26. Connection connection = null;
  27. Statement stmt = null;
  28.  
  29. try {
  30. connection = DriverManager
  31. .getConnection("jdbc:mysql://dataa","data", "sdata");
  32.  
  33. } catch (SQLException e) {
  34. System.out.println("Connection Failed! Check output console");
  35. e.printStackTrace();
  36. return;
  37. }
  38.  
  39. if (connection != null) {
  40. stmt = (Statement) connection.createStatement();
  41. String sql;
  42. sql = "SELECT productId FROM checkout WHERE playerName='" +username+ "' AND canClaim='1'";
  43. ResultSet rs = stmt.executeQuery(sql);
  44. while(rs.next()){
  45. int id = rs.getInt("productId");
  46. switch(id) {
  47. case 17:
  48. player.getInventory().add(new Item(13190, 1));
  49. break;
  50. case 18:
  51. player.getInventory().add(new Item(13191, 1));
  52. break;
  53. case 19:
  54. player.getInventory().add(new Item(13192, 1));
  55. break;
  56. case 20:
  57. player.getInventory().add(new Item(13193, 1));
  58. break;
  59. case 21:
  60. player.getInventory().add(new Item(13195, 1));
  61. break;
  62. case 22:
  63. player.getInventory().add(new Item(292, 1));
  64. break;
  65. case 24:
  66. player.getInventory().add(new Item(600, 1));
  67. break;
  68.  
  69. }
  70. }
  71. sql = "UPDATE checkout SET canClaim = '2' WHERE playerName='" +username+ "' AND canClaim='1'";
  72. stmt.execute(sql);
  73. rs.close();
  74. stmt.close();
  75. connection.close();
  76.  
  77. } else {
  78. System.out.println("Failed to make connection!");
  79. }
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement