Guest User

Untitled

a guest
May 25th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. private void reggy(ActionEvent event) {
  2. try {
  3. String username_text = username.getText().trim();
  4.  
  5. String password_text = password.getText().trim();
  6.  
  7. Connection conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/store","root","password");
  8. Statement st = (Statement) conn.createStatement();
  9. String sql = "select username, password from users where username ='"+username_text+"' and password ='"+password_text+"'";
  10. ResultSet rs;
  11. rs = st.executeQuery(sql);
  12.  
  13.  
  14.  
  15.  
  16. int count = 0;
  17. while(rs.next()) {
  18. count = count +1;
  19. }
  20. if(count == 1){
  21. AnchorPane pane = FXMLLoader.load(getClass().getResource("second.fxml"));
  22. rootpane.getChildren().setAll(pane);
  23. System.out.println("User Found, Logged in");
  24.  
  25. }
Add Comment
Please, Sign In to add comment