Guest User

Untitled

a guest
Apr 9th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. Connection conn = null;
  2.     java.sql.PreparedStatement ps = null;
  3.     ResultSet ds = null;
  4.     try {
  5.         conn = DriverManager.getConnection("jdbc:mysql://localhost:3307/minecraft_server","root", "");
  6.         ps = conn.prepareStatement("INSERT INTO packages (from, to, item, amount, damage, message, date, opened)" + "VALUES (?,?,?,?,?,?,?,?)",Statement.RETURN_GENERATED_KEYS);
  7.         ps.setInt(1, playerFrom);
  8.         ps.setInt(2, playerTo);
  9.         ps.setInt(3, sendItem);
  10.         ps.setInt(4, sendAmount);
  11.         ps.setInt(5, sendDamage);
  12.         ps.setString(6, message);
  13.         ps.setString(7, playerInformation.DateUtils.now());
  14.         ps.setInt(8, 0);
  15.         ps.executeUpdate();
  16.     }  catch (SQLException ex) {
  17.         log.info("[Package Send Command] - Unable to log unique message into SQL");
  18.         ex.printStackTrace();
  19.     } finally {
  20.         try {
  21.             if (ps != null)
  22.                
  23.                 player.sendMessage("Logged!");
  24.                
  25.             ps.close();
  26.             if (ds != null)
  27.                 ds.close();
  28.             if (conn != null)
  29.                 conn.close();
  30.         } catch (SQLException ex) {
  31.         }
  32.     }
Add Comment
Please, Sign In to add comment