I tried to create a login form and it is showing Column index is out of range. I have created two columns and I have used two columns but it is showing error.
String url = "jdbc:mysql://localhost:3306/login_form?useSSL=false";
String name = "Vzlys";
String Pass = "Vzlys@1995";
try
{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(url,name,Pass);
st = con.prepareStatement("select * from login where username = ? and password = ?");//here login is my table name
st.setString(1,txtusername.getText());
st.setString(2,txtpassword.getText());//error occurs here
rs = st.executeQuery();
JOptionPane.showMessageDialog(null,"Welcome");
ferrysql f = new ferrysql();
f.setVisible(true);
con.close();
st.close();
}
catch (Exception e)
{
JOptionPane.showMessageDialog(null,e);
}