use of org.springframework.jdbc.core.ConnectionCallback in project spring-boot by spring-projects.
the class AbstractDataSourcePoolMetadataTests method getIdle.
@Test
void getIdle() {
JdbcTemplate jdbcTemplate = new JdbcTemplate(getDataSourceMetadata().getDataSource());
jdbcTemplate.execute((ConnectionCallback<Void>) (connection) -> null);
assertThat(getDataSourceMetadata().getIdle()).isEqualTo(1);
}
use of org.springframework.jdbc.core.ConnectionCallback in project spring-boot by spring-projects.
the class AbstractDataSourcePoolMetadataTests method getPoolSizeOneConnection.
@Test
void getPoolSizeOneConnection() {
JdbcTemplate jdbcTemplate = new JdbcTemplate(getDataSourceMetadata().getDataSource());
jdbcTemplate.execute((ConnectionCallback<Void>) (connection) -> {
assertThat(getDataSourceMetadata().getActive()).isEqualTo(1);
assertThat(getDataSourceMetadata().getUsage()).isEqualTo(0.5f);
return null;
});
}
use of org.springframework.jdbc.core.ConnectionCallback in project spring-boot by spring-projects.
the class AbstractDataSourcePoolMetadataTests method getPoolSizeNoConnection.
@Test
void getPoolSizeNoConnection() {
// Make sure the pool is initialized
JdbcTemplate jdbcTemplate = new JdbcTemplate(getDataSourceMetadata().getDataSource());
jdbcTemplate.execute((ConnectionCallback<Void>) (connection) -> null);
assertThat(getDataSourceMetadata().getActive()).isEqualTo(0);
assertThat(getDataSourceMetadata().getUsage()).isEqualTo(0f);
}
use of org.springframework.jdbc.core.ConnectionCallback in project spring-data-jdbc by spring-projects.
the class DefaultJdbcTypeFactory method createArray.
@Override
public Array createArray(Object[] value) {
Assert.notNull(value, "Value must not be null.");
Class<?> componentType = arrayColumns.getArrayType(value.getClass());
SQLType jdbcType = JdbcUtil.targetSqlTypeFor(componentType);
Assert.notNull(jdbcType, () -> String.format("Couldn't determine JDBCType for %s", componentType));
String typeName = arrayColumns.getArrayTypeName(jdbcType);
return operations.execute((ConnectionCallback<Array>) c -> c.createArrayOf(typeName, value));
}
Aggregations