Hi i have a query where i select values from the database and i would like to do a comparison with the selected data. I am able to create the query and pass in the parameters but i am still having some problems accessing the values returned from the query. Can someone tell me if i am on the right track, i think i wrote the last two statements incorrectly.
String sql = "SELECT userName, password FROM tblusers WHERE userName = ? AND password = ? ";
Object[] parameters = new Object[] {login.getUserName(), login.getPassword()};
String dbUserName = (String)getJdbcTemplate().queryForObject(
sql, parameters, String.class);
String dbPassword = (String)getJdbcTemplate().queryForObject(
sql, parameters, String.class);
If your query returns only one record, I suggest you to use:
queryForMap(String sql, Object... args)Take a look at javadoc.
For your specific problem this should work: