You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[name]=? and [password]=?' at line 1
package com.login.dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import com.mysql.jdbc.PreparedStatement;
public class LoginDao
{
public boolean check(String uname ,String pass)
{
try
{
String url ="jdbc:mysql://localhost:3306/login";
String username = "root";
String password = "root";
String query = " select * from login where Name =? and
password=? ";
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/","root","root");
PreparedStatement st = (PreparedStatement) con.prepareStatement(query);
st.setString(1, uname);
st.setString(2, pass);
ResultSet rs = st.executeQuery(query);
if(rs.next())
{
return true;
}
}
catch (Exception e)
{
System.out.println("Mistake");
e.printStackTrace();
}
return false;
}
}