Using Standalone JdcbTemplate

We are exploring the use of JdbcTemplate to access the database — but we have many different DB connections that each class can use, so jdbcTemplate injection is not an atm parameter. So if we do

jdbcTemplate = new JdbcTemplate(dataSource);

What will be the transaction policy? Auto-commit is disabled in the database.

+3
source share
1 answer

You can configure each object javax.sql.DataSourceto enable auto-commit if it is a job, or automatically disable auto-commit and write transactional logic.

Both classes java.sql.Connectionand javax.sql.DataSourcehave methods to enable / disable auto-commit.

Spring, - . org.springframework.jdbc.core.support.JdbcDaoSupport, JdbcTemplate, getJdbcTemplate().

Spring . XA . @Transactional . . .

+2

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


All Articles