My question is about a Java Web program which search the database and returns the list of students as per the query The code is below:-
public class StudentDAO {
        public List<Student> getStudent(String s){
             List<Student> lst=new ArrayList<>();
             try{
                Context ctx =new InitialContext();
                DataSource ds=(DataSource)ctx.lookup("java:comp/env/jdbc/test");
                Connection con=ds.getConnection();
                Statement st = con.createStatement(); 
                ResultSet res=st.executeQuery("select * from student where "+s);
                while(res.next())
                {
                    lst.add(new Student(res.getString(1),res.getString(2),res.getString(3),res.getString(4)));               
                }
                res.close();
                con.close();
        }
        catch(Exception e){
            System.out.println("errrrr..."+e.getMessage());
        }
        return lst;
    }
}
Here 's' is the string containing categories based on which I want to search students. But I'm getting the following error :-
errrrr...executeQuery method can not be used for update.
 
     
    