• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

At least one parameter to the current statement is uninitialized ERROR

 
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Author
Posts: 143
15
Android Python Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you forget to call ps.setString(1, <email>) before executing the query?
 
Kazankingo Tico
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic