I had tried several times using prepared statements but it returns SQL exception. here is my code:
public ArrayList name(String mobile, String
For both parameter you use preparedStatement.setString(1, ..);
so the first parameter is set two times. but you never set the value for second parameter.
so change
preparedStatement.setString(1, mobile);
preparedStatement.setString(1, password);
to
preparedStatement.setString(1, mobile);
preparedStatement.setString(2, password);
You need to use:
preparedStatement.executeQuery();
instead of
preparedStatement.executeQuery(login);
when you pass in a string to executeQuery()
that query is executed literally and thus the ?
is send to the database which then creates the error. By passing query string you are not execution the "cached" prepared statement for which you passed the values.