Kazankingo Tico

Greenhorn
+ Follow
since Dec 03, 2021
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kazankingo Tico

I thank you very much. It did solve my issue. I really appreciate it.

Have a great day and thank you for taking the time to help me.
I am new to Java and derby and a little lost.

I am using jframe and derby. Trying to do an email / password validation. At first I was concatenating with statement but read online it is best to use prepared statements. While using email as primary key, with statement I was getting a Lexical error because of the '@'. Now , with prepared statement I am getting a
'At least one parameter to the current statement is uninitialized'.

Not sure if I am entering something wrong....

This is the method I created.



public void login() {
       if ((jtxtEmail.getText().equals(""))) {
           JOptionPane.showMessageDialog(null, "Debes ingresar tu email y contraseña.", "Error al ingresar Usuario y contraseña", JOptionPane.ERROR_MESSAGE);
       } else {
           try {
               conectar();
               ps = conn.prepareStatement("select email,password,nombre from Usuarios where email=?");
               ResultSet rs = ps.executeQuery();
               while (rs.next()) {
                   if (rs.getString(1).equals(jtxtEmail.getText()) && rs.getString(2).equals(jtxtPassword.getText())){
                       JOptionPane.showMessageDialog(null, "Bienvenido"+rs.getString(3), "Validacion Correcta", JOptionPane.INFORMATION_MESSAGE);
                       new DirectoryMale().setVisible(true);
                   }else{
                       JOptionPane.showMessageDialog(null, "Debes ingresar tu email y contraseña.", "Error al ingresar Usuario y contraseña", JOptionPane.ERROR_MESSAGE);
                   }
               }
               desconectar();
               ps.close();
           } catch (HeadlessException | SQLException ex) {
               JOptionPane.showMessageDialog(null, "Error.\n" + ex.getMessage());
           }
       }
   }


Thanks a lot for helping a noob, lol...
6 months ago