I'm not quite sure how to formulate the question, so feel free to tell me what I think is completely wrong.
I want to use JdbcTemplateand TransactionTemplate. Am I starting out by initializing my connection pool as a data source and creating a transaction manager as a data source?
BoneCPConfig connectionPoolConfig = new BoneCPConfig();
connectionPoolConfig.setJdbcUrl(...);
connectionPoolConfig.setUsername(...);
connectionPoolConfig.setPassword(...);
connectionPoolConfig.setMinConnectionsPerPartition(...);
connectionPoolConfig.setMaxConnectionsPerPartition(...);
dataSource = new BoneCPDataSource(connectionPoolConfig);
DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
definition.setIsolationLevel(TransactionDefinition.ISOLATION_READ_COMMITTED);
DataSourceTransactionManager transactionManager = new DataSourceTransactionManager();
transactionManager.setDataSource(dataSource);
But now I want to create my TransactionTemplate and JdbcTemplate:
transactionTemplate = new TransactionTemplate(transactionManager);
JdbcTemplate jdbc = new JdbcTemplate(transactionManager.getDataSource());
Now mulitple threads access TransactionTemplateand jdbc. Does this code ensure that everything done in doInTransactionuses the same connection for all jdbc calls?
- , , JdbcTemplate TransactionTemplate , . /?