本文整理匯總了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();
}