本文整理汇总了Java中org.apache.commons.dbcp2.BasicDataSource.close方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDataSource.close方法的具体用法?Java BasicDataSource.close怎么用?Java BasicDataSource.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.dbcp2.BasicDataSource
的用法示例。
在下文中一共展示了BasicDataSource.close方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Test
public void test() throws SQLException {
BasicDataSource dataSource = getDataSource("");
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.execute("CREATE TABLE employee (id INTEGER)");
dataSource.close();
List<MockSpan> finishedSpans = mockTracer.finishedSpans();
assertEquals(1, finishedSpans.size());
checkTags(finishedSpans, "myservice", "jdbc:hsqldb:mem:spring");
checkSameTrace(finishedSpans);
assertNull(mockTracer.scopeManager().active());
}
示例2: testWithSpanOnlyWithParent
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Test
public void testWithSpanOnlyWithParent() throws SQLException {
try (Scope activeSpan = mockTracer.buildSpan("parent").startActive(true)) {
BasicDataSource dataSource = getDataSource(";traceWithActiveSpanOnly=true");
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.execute("CREATE TABLE with_parent_skip (id INTEGER)");
dataSource.close();
}
List<MockSpan> finishedSpans = mockTracer.finishedSpans();
assertEquals(2, finishedSpans.size());
checkSameTrace(finishedSpans);
assertNull(mockTracer.scopeManager().active());
}
示例3: spring
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Test
public void spring() throws SQLException {
BasicDataSource dataSource = getDataSource(false);
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.execute("CREATE TABLE employee (id INTEGER)");
dataSource.close();
List<MockSpan> finishedSpans = mockTracer.finishedSpans();
assertEquals(1, finishedSpans.size());
MockSpan mockSpan = finishedSpans.get(0);
assertEquals(Tags.SPAN_KIND_CLIENT, mockSpan.tags().get(Tags.SPAN_KIND.getKey()));
assertEquals(JdbcTracingUtils.COMPONENT_NAME, mockSpan.tags().get(Tags.COMPONENT.getKey()));
assertThat(mockSpan.tags().get(Tags.DB_STATEMENT.getKey()).toString()).isNotEmpty();
assertEquals("h2", mockSpan.tags().get(Tags.DB_TYPE.getKey()));
assertEquals("sa", mockSpan.tags().get(Tags.DB_USER.getKey()));
assertEquals(0, mockSpan.generatedErrors().size());
assertNull(mockTracer.activeSpan());
}
示例4: spring_with_parent
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Test
public void spring_with_parent() throws Exception {
try (Scope ignored = mockTracer.buildSpan("parent").startActive(true)) {
BasicDataSource dataSource = getDataSource(false);
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.execute("CREATE TABLE with_parent_1 (id INTEGER)");
jdbcTemplate.execute("CREATE TABLE with_parent_2 (id INTEGER)");
dataSource.close();
}
List<MockSpan> spans = mockTracer.finishedSpans();
assertEquals(3, spans.size());
checkSameTrace(spans);
}
示例5: spring_with_parent_and_active_span_only
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Test
public void spring_with_parent_and_active_span_only() throws Exception {
try (Scope ignored = mockTracer.buildSpan("parent").startActive(true)) {
BasicDataSource dataSource = getDataSource(true);
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.execute("CREATE TABLE with_parent_skip_1 (id INTEGER)");
jdbcTemplate.execute("CREATE TABLE with_parent_skip_2 (id INTEGER)");
dataSource.close();
}
List<MockSpan> spans = mockTracer.finishedSpans();
assertEquals(3, spans.size());
checkSameTrace(spans);
}
示例6: shutdownBasicDataSources
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
/**
* 關閉
*
* @return
*/
protected BasicDataSource[] shutdownBasicDataSources() throws Exception {
try {
if (this.basicDataSources != null) {
for (int i = 0; i < this.basicDataSources.length; i++) {
BasicDataSource oldInstance = this.basicDataSources[i];
oldInstance.close();
this.basicDataSources[i] = null;
}
//
this.basicDataSources = null;
}
} catch (Exception e) {
LOGGER.error(new StringBuilder("Exception encountered during shutdownBasicDataSources()").toString(), e);
throw e;
}
return this.basicDataSources;
}
示例7: testWithSpanOnlyNoParent
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Test
public void testWithSpanOnlyNoParent() throws SQLException {
BasicDataSource dataSource = getDataSource(";traceWithActiveSpanOnly=true");
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.execute("CREATE TABLE skip_new_spans (id INTEGER)");
dataSource.close();
List<MockSpan> finishedSpans = mockTracer.finishedSpans();
assertEquals(0, finishedSpans.size());
assertNull(mockTracer.scopeManager().active());
}
示例8: batch
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Test
public void batch() throws SQLException {
BasicDataSource dataSource = getDataSource(false);
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.execute("CREATE TABLE batch (id INTEGER)");
final List<Integer> ids = Arrays.asList(1, 2, 3, 4, 5);
jdbcTemplate.batchUpdate("INSERT INTO batch (id) VALUES (?)",
new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement preparedStatement, int i) throws SQLException {
preparedStatement.setInt(1, ids.get(i));
}
@Override
public int getBatchSize() {
return ids.size();
}
}
);
dataSource.close();
List<MockSpan> spans = mockTracer.finishedSpans();
assertEquals(2, spans.size());
for (MockSpan span : spans) {
assertEquals(Tags.SPAN_KIND_CLIENT, span.tags().get(Tags.SPAN_KIND.getKey()));
assertEquals(JdbcTracingUtils.COMPONENT_NAME, span.tags().get(Tags.COMPONENT.getKey()));
assertThat(span.tags().get(Tags.DB_STATEMENT.getKey()).toString()).isNotEmpty();
assertEquals("h2", span.tags().get(Tags.DB_TYPE.getKey()));
assertEquals("sa", span.tags().get(Tags.DB_USER.getKey()));
assertEquals(0, span.generatedErrors().size());
}
assertNull(mockTracer.activeSpan());
}
示例9: spring_active_span_only
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Test
public void spring_active_span_only() throws Exception {
BasicDataSource dataSource = getDataSource(true);
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.execute("CREATE TABLE skip_new_spans (id INTEGER)");
dataSource.close();
List<MockSpan> finishedSpans = mockTracer.finishedSpans();
assertEquals(0, finishedSpans.size());
}
示例10: afterAll
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Override
public void afterAll(final TestInvocation invocation) throws Exception {
final ExecutionContext context = invocation.getContext();
final BasicDataSource ds = (BasicDataSource) context.getData(Constants.KEY_DATA_SOURCE);
ds.close();
context.storeData(Constants.KEY_DATA_SOURCE, null);
}
示例11: closeAll
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public void closeAll() throws SQLException {
for (BasicDataSource datasource : cache.asMap().values()) {
LOG.info("close DataSource:" + datasource);
datasource.close();
}
cache.invalidateAll();
}
示例12: shutdownBasicDataSource
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
/**
* 關閉
*
* @return
*/
protected BasicDataSource shutdownBasicDataSource() throws Exception {
try {
if (this.basicDataSource != null) {
BasicDataSource oldInstance = this.basicDataSource;
oldInstance.close();
this.basicDataSource = null;
}
} catch (Exception e) {
LOGGER.error(new StringBuilder("Exception encountered during shutdownBasicDataSource()").toString(), e);
throw e;
}
return this.basicDataSource;
}
示例13: shutdownDataSource
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
public static void shutdownDataSource(DataSource ds) throws SQLException {
BasicDataSource bds = (BasicDataSource) ds;
bds.close();
}
示例14: passivateDataSourcePool
import org.apache.commons.dbcp2.BasicDataSource; //导入方法依赖的package包/类
@Override
protected void passivateDataSourcePool( BasicDataSource dataSourcePool )
throws Exception
{
dataSourcePool.close();
}