use of org.apache.tomcat.jdbc.pool.DataSource in project spring-boot by spring-projects.
the class TomcatDataSourcePoolMetadataTests method createDataSource.
private DataSource createDataSource(int minSize, int maxSize) {
DataSource dataSource = (DataSource) initializeBuilder().type(DataSource.class).build();
dataSource.setMinIdle(minSize);
dataSource.setMaxActive(maxSize);
// Avoid warnings
dataSource.setInitialSize(minSize);
dataSource.setMaxIdle(maxSize);
return dataSource;
}
use of org.apache.tomcat.jdbc.pool.DataSource in project spring-boot by spring-projects.
the class TomcatDataSourcePoolMetadataTests method getValidationQuery.
@Override
public void getValidationQuery() {
DataSource dataSource = createDataSource(0, 4);
dataSource.setValidationQuery("SELECT FROM FOO");
assertThat(new TomcatDataSourcePoolMetadata(dataSource).getValidationQuery()).isEqualTo("SELECT FROM FOO");
}
use of org.apache.tomcat.jdbc.pool.DataSource in project Gargoyle by callakrsos.
the class FxDAOReadFunction method apply.
@Override
public TbmSysDaoDVO apply(TbmSysDaoDVO t) {
DataSource dataSource = null;
try {
dataSource = DbUtil.getDataSource();
boolean existsSchemaDatabase = DbUtil.isExistsSchemaDatabase();
List<TbpSysDaoMethodsDVO> methods = getMethod(dataSource, t, existsSchemaDatabase);
List<TbpSysDaoColumnsDVO> columns = getColumns(dataSource, t, existsSchemaDatabase);
List<TbpSysDaoFieldsDVO> fields = getField(dataSource, t, existsSchemaDatabase);
for (TbpSysDaoMethodsDVO m : methods) {
m.setTbpSysDaoColumnsDVOList(columns.stream().filter(col -> m.getMethodName().equals(col.getMethodName())).collect(Collectors.toList()));
m.setTbpSysDaoFieldsDVOList(fields.stream().filter(col -> m.getMethodName().equals(col.getMethodName())).collect(Collectors.toList()));
}
t.setTbpSysDaoMethodsDVOList(methods);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
DbUtil.close(dataSource);
} catch (Exception e) {
}
}
return t;
}
use of org.apache.tomcat.jdbc.pool.DataSource in project Gargoyle by callakrsos.
the class DbUtil method select.
/**
* SQL을 실행하고 결과를 반환
*
* @param sql
* @return
* @throws Exception
*/
public static <T> List<T> select(final String sql, MapSqlParameterSource paramMap, RowMapper<T> rowMapper) throws Exception {
DataSource dataSource = null;
List<T> query = null;
try {
noticeQuery(sql);
dataSource = getDataSource();
NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
// String _sql = ValueUtil.getVelocityToText(sql,
// paramMap.getValues());
query = jdbcTemplate.query(sql, paramMap, rowMapper);
} catch (Exception e) {
// cleanDataSource();
// close(dataSource);
LOGGER.error(ValueUtil.toString(e));
throw e;
} finally {
cleanDataSource();
// close(dataSource);
}
return query;
}
use of org.apache.tomcat.jdbc.pool.DataSource in project Gargoyle by callakrsos.
the class DbUtil method select.
/**
* SQL을 실행하고 결과를 반환
*
* @param sql
* @return
* @throws Exception
*/
public static <T> List<T> select(final String sql, Map<String, Object> paramMap, RowMapper<T> rowMapper) throws Exception {
DataSource dataSource = null;
List<T> query = null;
try {
dataSource = getDataSource();
query = select(dataSource, sql, paramMap, rowMapper);
} catch (Exception e) {
LOGGER.error(ValueUtil.toString(e));
query = Collections.emptyList();
} finally {
close(dataSource);
}
return query;
}
Aggregations