Answers for "spring 5 jdbctemplate query for a single value"

0

spring 5 jdbctemplate query for a single value

String result = DataAccessUtils.singleResult(
    jdbcTemplate.queryForList(
        "SELECT street_name FROM table WHERE id = :id",
        Collections.singletonMap("id", id),
        String.class
    )
)
Posted by: Guest on October-23-2021
0

spring 5 jdbctemplate query for a single value

public String getStreetNameById(int id) {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    String sql = "SELECT STREET_NAME FROM table WHERE ID=?";

    String streetName = (String) jdbcTemplate.queryForObject(
            sql, String.class, id);

    return streetName;
}
Posted by: Guest on October-23-2021

Code answers related to "spring 5 jdbctemplate query for a single value"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language