Advertisement
Guest User

Untitled

a guest
Feb 10th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. private void submitActionPerformed(java.awt.event.ActionEvent evt) {
  2. // TODO add your handling code here:
  3. Connection con;
  4. try{
  5. Class.forName("com.mysql.jdbc.Driver");
  6. con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/autoexotic","root","");
  7. String insertRow = "INSERT INTO users(username, password) VALUES (?,?)";
  8. PreparedStatement statement = con.prepareStatement(insertRow);
  9. statement.setString(1, userField.getText());
  10. statement.setString(2, new String(passwordField.getPassword()));
  11. // statement.setString(3, "ACTIVE");
  12. //statement.setString(4, "0");
  13. int rowsInserted = statement.executeUpdate();
  14. if (rowsInserted > 0){
  15. output.setText("Staff Account Created: " + userField.getText());
  16. jTable1.repaint();
  17. } else{
  18. output.setText("Sorry, an error occured while creating the new account!");
  19. statement.close();
  20. con.close();
  21. }
  22. }catch(Exception e){
  23. System.out.println(e);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement