I am getting some error stating executing query is passing null value. can any body help me. I am trying to connect to my local database, extract value and if the input value and value in database matches,it eventually will log in. but there is something error that I couldn't figure what is wrong. I checked the drivers and modules but they are doing fine.
@Override
public void actionPerformed(ActionEvent ae) {
if(ae.getSource()==b1){
String user=t1.getText();
String password =t2.getText();
MySQLConnection conn = new MySQLConnection();
String st = "select * from hotel where username='"+user+"' and password='"+password+"'";
try {
ResultSet se= conn.s.executeQuery(st);
if(se.next()){
new HotelManagementSystem().setVisible(true);
}
else{
JOptionPane.showMessageDialog(null,"Invalid username or password");
}
this.setVisible(false);
}
catch (Exception e){
e.printStackTrace();
}
}
else if(ae.getSource()==b2){
System.exit(0);
}
}
public class MySQLConnection {
Connection c;
Statement s;
public MySQLConnection() {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/hotel", "root", "");
Statement s = c.createStatement();
} catch (Exception e) {
e.printStackTrace();
}
}
}