Guest User

Untitled

a guest
Jun 27th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1.   } else if (splitted[0].equalsIgnoreCase("!newacc")) {
  2.             if (splitted.length < 4) {
  3.                 mc.dropMessage("!newacc <id> <name> <password> <email>");
  4.             } else {
  5.                 try {
  6.                     Connection con = DatabaseConnection.getConnection();
  7.                     PreparedStatement ps = con.prepareStatement("INSERT INTO account (id, name, password, email) VALUES (?, ?, ?, ?)");
  8.        ps.setInt(1, splitted[1]); // id has auto increment, so it's not used.
  9.        ps.setString(2, splitted[2]); // account name.
  10.        ps.setString(3, LoginCrypto.hexSha1(splitted[3]));
  11.        ps.setString(4, splitted[4]); // email.
  12.                     ps.executeUpdate();
  13.                     ps.close();
  14.                     mc.dropMessage("Account creation sucess. Username: " + splitted[2] + ". Password: " + splitted[3] + ".");
  15.                 } catch (SQLException e) {
  16.                     mc.dropMessage("Error creating a new account, Please read Batch Errors for more information");
  17.                 }
  18.             }
  19.         }
Add Comment
Please, Sign In to add comment