Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mysql.impl;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.Connection;
- import java.sql.SQLException;
- import com.aldorps.model.Item;
- import com.aldorps.world.entity.impl.player.Player;
- import com.mysql.jdbc.Statement;
- public class Donation {
- public static void checkDonation(String username, Player player) throws SQLException {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- return;
- }
- Connection connection = null;
- Statement stmt = null;
- try {
- connection = DriverManager.getConnection("jdbc:mysql://158.69.223.170:3306/webstore","webstore", "aqyqPErAYvaGCajB");
- } catch (SQLException e) {
- e.printStackTrace();
- return;
- }
- boolean space = false;
- if (connection != null) {
- System.out.println(1);
- stmt = (Statement) connection.createStatement();
- String sql;
- sql = "SELECT productId FROM checkout WHERE playerName='" +username+ "' AND canClaim='1'";
- ResultSet rs = stmt.executeQuery(sql);
- while(rs.next()){
- int id = rs.getInt("productId");
- if(player.getInventory().getFreeSlots() >= 1) {
- switch(id) {
- case 17:
- //1$ scroll
- break;
- case 18:
- //5$ scroll
- break;
- case 19:
- //10$ scroll
- break;
- case 20:
- //25$ scroll
- break;
- case 21:
- //50$ scroll
- break;
- case 22:
- //100$ scroll
- break;
- }
- } else {
- space = true;
- }
- }
- if(!space) {
- sql = "UPDATE checkout SET canClaim = '2' WHERE playerName='" +username+ "' AND canClaim='1'";
- stmt.execute(sql);
- }
- rs.close();
- stmt.close();
- connection.close();
- } else {
- System.out.println("Failed to make connection!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement