First of all before i created this dao I was doing this operation in a helper class and it was working well. Now I'm getting a NullpointerException
on this line where I call dao.
Student stu = pf.getUser(request.getParameter("st_id").toString());
I tried to trace it and find the problem but i couldn't.
I'm new in jdbc so any suggestions will be appreciated.
This is my student dao; program doesn't even enter the getUser
method.
public class StDAO extends BaseDAO {
public Student getUser(String Id) throws Exception {
String query = "select * from students where id=" + Id;
ResultSet rs = execQuery(query);
return new Student(rs.getString("name"), Id, rs.getString("gpa"));
}
public void addUser(String id, String name, String gpa) throws Exception {
String query = "INSERT INTO students (name, id, `gpa`) VALUES ('" + name + "'," + id + "," + gpa + ")";
ResultSet rs = execQuery(query);
}
}