0

i have a error here anyone know how to fix it? i got no idea which part i missed. in lib i already import the jar.

 String sql ="SELECT`username`,`password`FROM userdetail WHERE `username = ?``password = ?`";

try{

    con = DriverManager.getConnection("jdbc:mysql://localhost/logininfo","root","");
    pst = con.prepareStatement(sql);
    pst.setString(1,username.getText());
    pst.setString(2,password.getText());
    rs=pst.executeQuery();
    if(rs.next())
    {
        JOptionPane.showMessageDialog(null, "username and password matched");
 }
    else{
        JOptionPane.showMessageDialog(null, "username and password do not matched");
    }
}catch(Exception ex)
{
    JOptionPane.showMessageDialog(null,ex);
}

my database

here the error

Thomas.Chan
  • 31
  • 2
  • 9
  • Do you have the mysql jar file on your classpath (at runtime, not only during compilation)? – Thilo Apr 29 '18 at 04:27
  • Also, your SQL WHERE seems to miss an AND and makes weird use of backticks. – Thilo Apr 29 '18 at 04:28
  • i don't really understand i am new in netbeans.... can you please explain to me? – Thomas.Chan Apr 29 '18 at 04:28
  • when i use this line still got that error -----> "select * from userdetail where username=? and password=?" – Thomas.Chan Apr 29 '18 at 04:30
  • See this: https://stackoverflow.com/questions/1911253/the-infamous-java-sql-sqlexception-no-suitable-driver-found and this: https://stackoverflow.com/questions/36974534 – Stephen C Apr 29 '18 at 04:49
  • 1
    The problem is that you don't have the JAR on the classpath when you run the code. The precise solution depends on how you are running your code. – Stephen C Apr 29 '18 at 04:50
  • yeah...i solved thanks for the help... i just remove all the jar and import again then the error disappear. – Thomas.Chan Apr 29 '18 at 06:12

0 Answers0