I have select:
SELECT hz FROM my_tablw WHERE id=1
It return me 1 row and 1 column:
hz
some data
I have
@Autowired
private NamedParameterJdbcTemplate jdbcTemplate;
And I need make query and return 1 row - String some data
.
I create
jdbcTemplate.query("SELECT hz FROM my_tablw WHERE id=:id", insertManagerParameters, (rs, rowNum) -> {
if (rs.next()) {
return rs.getString(1);
}
return "";
});
but this method return List<String>
I would use the queryForObject
method, like:
jdbcTemplate.queryForObject("SELECT hz FROM my_tablw WHERE id=:id", insertManagerParameters, String.class);
Which should return a String
with the query results.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With