Note that there are some explanatory texts on larger screens.

plurals
  1. POError show java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0)
    primarykey
    data
    text
    <p>I have three table 1.User 2.Branch 3 userbranch. I have trying to solve login form. but when login button is click it's show this error java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).</p> <pre><code>public Boolean loginApplication(Connection con, String uname, String pwd, String brnch) { try { PreparedStatement ps = con.prepareStatement("Select u.username,u.password," + "b.branchname from user u, branch b ,userbranch ub" + "where u.userid = ub.userid and b.branchid=ub.branchid "); ps.setString(1, uname); ps.setString(2, pwd); ps.setString(3, brnch); ResultSet rs = ps.executeQuery(); System.out.println("query return " + rs); if (rs.next()) { return true; //true if query found any corresponding data } else{ return false; } } catch (SQLException ex) { System.out.println("Error while validating " + ex); return false; } } private void buttonloginActionPerformed(java.awt.event.ActionEvent evt) { String uname=username.getText(); String upass=userpassword.getText(); String ubranch=userbranch.getSelectedItem().toString().trim(); if(evt.getSource()==buttonlogin){ if(user.loginApplication(connect.getCon(),uname,upass,ubranch)){ System.out.println("success"); MainForm mainForm=new MainForm(); mainForm.setVisible(true); } } else{ JOptionPane.showMessageDialog(null, "Login failed!","Failed!!", JOptionPane.ERROR_MESSAGE); } } </code></pre> <p>Shows error: </p> <pre><code>java.sql.SQLException: Parameter index out of range (1 &gt; number of parameters, which is 0). </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload