How to get the number of rows affected from a JdbcTemplate?

I use spring JdbcTemplateto execute an SQL query:

JdbcTemplate template = new JdbcTemplate(ds);
template.execute(sqlInsert); //returns void

How can I get the number of rows, how execute()does the method return void?

+4
source share
2 answers

Call the update method JdbcTemplate. It will give you the number of rows processed as the return value.

+8
source

You can use JdbcTemplate.update()for this occasion. this will return the number of updated or deleted rows.

+1
source

Source: https://habr.com/ru/post/1570867/


All Articles