use of cn.taketoday.jdbc.core.JdbcTemplate in project today-framework by TAKETODAY.
the class InferredDataSourceSqlScriptsTests method database1.
@Test
@Sql(scripts = "data-add-dogbert.sql", config = @SqlConfig(transactionManager = "txMgr1"))
void database1() {
TransactionAssert.assertThatTransaction().isNotActive();
assertUsers(new JdbcTemplate(dataSource1), "Dilbert", "Dogbert");
}
use of cn.taketoday.jdbc.core.JdbcTemplate in project today-framework by TAKETODAY.
the class InferredDataSourceSqlScriptsTests method database2.
@Test
@Sql(scripts = "data-add-catbert.sql", config = @SqlConfig(transactionManager = "txMgr2"))
void database2() {
TransactionAssert.assertThatTransaction().isNotActive();
assertUsers(new JdbcTemplate(dataSource2), "Dilbert", "Catbert");
}
use of cn.taketoday.jdbc.core.JdbcTemplate in project today-framework by TAKETODAY.
the class InferredDataSourceTransactionalSqlScriptsTests method database2.
@Test
@Transactional("txMgr2")
@Sql(scripts = "data-add-catbert.sql", config = @SqlConfig(transactionManager = "txMgr2"))
void database2() {
assertThatTransaction().isActive();
assertUsers(new JdbcTemplate(dataSource2), "Dilbert", "Catbert");
}
use of cn.taketoday.jdbc.core.JdbcTemplate in project today-framework by TAKETODAY.
the class JdbcDataAccessObjectSupport method getExceptionTranslator.
/**
* Return the SQLExceptionTranslator of this DAO's JdbcTemplate,
* for translating SQLExceptions in custom JDBC access code.
*
* @see cn.taketoday.jdbc.core.JdbcTemplate#getExceptionTranslator()
*/
protected final SQLExceptionTranslator getExceptionTranslator() {
JdbcTemplate jdbcTemplate = getJdbcTemplate();
Assert.state(jdbcTemplate != null, "No JdbcTemplate set");
return jdbcTemplate.getExceptionTranslator();
}
use of cn.taketoday.jdbc.core.JdbcTemplate in project today-framework by TAKETODAY.
the class JdbcTemplateConfiguration method jdbcTemplate.
@Bean
@Primary
JdbcTemplate jdbcTemplate(DataSource dataSource, JdbcProperties properties) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
JdbcProperties.Template template = properties.getTemplate();
jdbcTemplate.setFetchSize(template.getFetchSize());
jdbcTemplate.setMaxRows(template.getMaxRows());
if (template.getQueryTimeout() != null) {
jdbcTemplate.setQueryTimeout((int) template.getQueryTimeout().getSeconds());
}
return jdbcTemplate;
}
Aggregations