Hi i current have a query that I'm trying to run however every time i try to run this query i get an array index out of bounds, I'm not sure why this is as i have not declared any arrays in my code, can anyone help?
public void actionPerformed(ActionEvent argO) {
try{
String query="select * from Users where Username ='admin' and password='password2' ";
PreparedStatement pst=connection.prepareStatement(query);
pst.setString(1, text_username.getText());
pst.setString(2, passwordField.getText());
ResultSet rs=pst.executeQuery();
int count=0;
while(rs.next())
{
count=count+1;
}
if(count==1)
{
JOptionPane.showMessageDialog(null, "Username and password is correct");
frmMychatApp.dispose();
AdminPage admin = new AdminPage();
admin.setVisible(true);
}
else if(count>1)
{
JOptionPane.showMessageDialog(null, "Duplicate Username and password");
}
else{
JOptionPane.showConfirmDialog(null, "Username and password is not correct. Please Try Again");
}
rs.close();
pst.close();
}catch (Exception e)
{
JOptionPane.showMessageDialog(null, e);
e.printStackTrace();
}