I am making a program for my school store, and would like some assistance from you brilliant people.
I've looked through SQL tutorials on the workbench, and I've looked up some videos on how to do what I'd like to achieve, but, I'm terrible with SQL for the time being. I have a snippet of my code, and it'd be wonderful if one of you better-versed with SQL could help me out with the errors.
class loginButton implements ActionListener{
public void actionPerformed(ActionEvent e) {
Connection connection;
PreparedStatement ps;
try {
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/userlist", "root", "Hadasada3!");
ps = connection.prepareStatement("SELECT `username`, `password` FROM `userlist` WHERE `username` = ? AND `password` = ?");
ps.setString(1, textUsername.getText());
ps.setString(2, String.valueOf(textPassword.getPassword()));
ResultSet result = ps.executeQuery();
if(result.next()){
JOptionPane.showMessageDialog(null, "Login Success.");
String[] args = null;
CowboyCorral.main(args);
dispose();
}
else{
JOptionPane.showMessageDialog(null, "Login Failed.");
}
} catch (SQLException ex) {
Logger.getLogger(CCLogin.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
buttonLogin.addActionListener(new loginButton());
I'm using Eclipse, and a modified example code from workbench. I have the SQL workbench running a database on localhost on port 3306, the SCHEMA and the table is called userlist.When this code is in text, it shows no errors. When I run the program and push the login button, it says No suitable driver found for jdbc:mysql://localhost:3306/userlist. I can give additional error information if needed, but if someone could point me in the right direction, or maybe even tell me where my fault is, that would be greatly appreciated.
I also have the mysql-connector-java-5.1.38-bin.jar in my referenced libraries of the project.