SHOW:
|
|
- or go back to the newest paste.
1 | - | public class SQL { |
1 | + | public static void addPlayer(Integer value) { |
2 | ||
3 | - | private static Connection con; //What we use to connect to all the databases. Essentially an IP. |
3 | + | |
4 | - | |
4 | + | PreparedStatement playersUpdate = con.prepareStatement("UPDATE tablename SET online=? WHERE players=?;"); |
5 | - | public static void closeConnection() { |
5 | + | //^^This is you getting what your putting it into. |
6 | coinsUpdate.setInt(1, value); //Update it to what value you put in | |
7 | - | if (con != null && !con.isClosed()) { //If the connection is open, then close it. |
7 | + | coinsUpdate.executeUpdate(); //Execute all the updates. |
8 | - | con.close(); |
8 | + | coinsUpdate.close(); |
9 | - | } |
9 | + | } catch (SQLException e) { |
10 | - | } catch (SQLException e) { //If you run into an error, |
10 | + | e.printStackTrace(); //Should NEVER error unless the SQL database is offline & the server is online. |
11 | - | e.printStackTrace(); //Then print the error log. |
11 | + | } |
12 | - | } |
12 | + | |
13 | } |