Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void login () {
- PreparedStatement st=null;
- ResultSet result=null;
- Connection conn=ConnexioDB.getConnexion();
- try{
- st=conn.prepareStatement("SELECT * FROM users WHERE USERNAME=? AND PASSWORD=?");
- st.setString(1,textfield.getText());
- if(checkBox.isSelected()) {
- st.setString(2, passwordField.getText());
- }else {
- st.setString(2,passwordField.getText());
- }
- result=st.executeQuery();
- if(result.next()){
- Alert alert=new Alert(Alert.AlertType.CONFIRMATION,"Login successfully",ButtonType.OK);
- alert.show();
- }
- else {
- Alert alert =new Alert(Alert.AlertType.WARNING,"Login errore // Password o username false",ButtonType.PREVIOUS);
- alert.show();
- }
- }catch (Exception e){
- throw new RuntimeException(e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment