Reputation: 706
i have used the following code(addAStudent and login methods )to perform Register and login operation for a simple Student Management System. I can able to execute the addAStudent method without any issues, but i am unable to execute the login method
@Override
public void addAStudent(String firstName, String lastName, String middleName, String username, String password, String emailId)
{
JdbcTemplate jdbcTemplate=new JdbcTemplate(dataSource);
jdbcTemplate.update("insert into Student(email_id,first_name,last_name,middle_name,password,username) values(?,?,?,?,?,?)",emailId,firstName,lastName,middleName,password,username);
}
@Override
public void login(String username,String password)
{
JdbcTemplate jdbcTemplate=new JdbcTemplate(dataSource);
jdbcTemplate.query("select * from student_info where uname=? and password=?",username,password);
}
please tell me, what is my mistake
Upvotes: 0
Views: 298
Reputation: 9437
If yuo use java 8 then select like:
jdbcTemplate.query("SELECT s.username as c1, s.password as c2 from student s where s.username = ? and s.password = ?",
new Object[]{username,password}),
(rs ->{
Student student = new Student();
student.username = rs.getString("c1");
student.passwrod = rs.getString("c2");
return student;
});
i think your table name student
.
jdbcTemplate.update("insert into student(email_id,first_name,last_name,middle_name,password,username) values(?,?,?,?,?,?)",emailId,firstName,lastName,middleName,password,username);
Upvotes: 1