本文整理汇总了Java中org.apache.commons.dbcp.BasicDataSource.close方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDataSource.close方法的具体用法?Java BasicDataSource.close怎么用?Java BasicDataSource.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.dbcp.BasicDataSource
的用法示例。
在下文中一共展示了BasicDataSource.close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: destroyDataSource
import org.apache.commons.dbcp.BasicDataSource; //导入方法依赖的package包/类
public void destroyDataSource(DataSource dataSource) {
try {
// for filter to destroy custom datasource
if (letHandlerDestroyIfSupport(0L, dataSource)) {
return;
}
if (dataSource == null) {
return;
}
BasicDataSource basicDataSource = (BasicDataSource) dataSource;
basicDataSource.close();
} catch (SQLException e) {
logger.error("ERROR ## close the datasource has an error", e);
}
}
示例2: destroy
import org.apache.commons.dbcp.BasicDataSource; //导入方法依赖的package包/类
public void destroy(Long pipelineId) {
Map<DbMediaSource, DataSource> sources = dataSources.remove(pipelineId);
if (sources != null) {
for (DataSource source : sources.values()) {
try {
// for filter to destroy custom datasource
if (letHandlerDestroyIfSupport(pipelineId, source)) {
continue;
}
// fallback for regular destroy
// TODO need to integrate to handler
BasicDataSource basicDataSource = (BasicDataSource) source;
basicDataSource.close();
} catch (SQLException e) {
logger.error("ERROR ## close the datasource has an error", e);
}
}
sources.clear();
}
}
示例3: test
import org.apache.commons.dbcp.BasicDataSource; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
try (Server server = new Server(new ServerConfiguration(folder.newFolder().toPath()))) {
server.start();
BasicDataSource dataSource = new BasicDataSource();
dataSource.setUrl("jdbc:herddb:server:localhost:7000?");
dataSource.setDriverClassName(Driver.class.getName());
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery("SELECT * FROM SYSTABLES")) {
int count = 0;
while (rs.next()) {
System.out.println("table: " + rs.getString(1));
count++;
}
assertTrue(count > 0);
}
dataSource.close();
}
}
示例4: destory
import org.apache.commons.dbcp.BasicDataSource; //导入方法依赖的package包/类
public synchronized void destory() throws SQLException {
if (delegate != null) {
BasicDataSource basicDataSource = (BasicDataSource) delegate;
basicDataSource.close();
delegate = null;
}
if (dataSourceSupplier != null) {
dataSourceSupplier.stop();
dataSourceSupplier = null;
}
}
示例5: runImportExportTest_Export
import org.apache.commons.dbcp.BasicDataSource; //导入方法依赖的package包/类
static void runImportExportTest_Export(final String clientUrl,
final String userName, final String password,
final String schemaFileName, final String dataFileName) throws Throwable {
// first dump this to XML
String dbtype = (new PlatformUtils()).determineDatabaseType(
"com.pivotal.gemfirexd.jdbc.ClientDriver", "jdbc:gemfirexd://" + clientUrl);
getLogger().info("DB TYPE = " + dbtype);
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName("com.pivotal.gemfirexd.jdbc.ClientDriver");
dataSource.setUrl("jdbc:gemfirexd://" + clientUrl);
if (userName != null) {
dataSource.setUsername(userName);
dataSource.setPassword(password);
}
DatabaseToDdlTask fromDBTask = new DatabaseToDdlTask();
fromDBTask.addConfiguredDatabase(dataSource);
fromDBTask.setDatabaseType(dbtype);
WriteSchemaToFileCommand writeSchemaToFile = new WriteSchemaToFileCommand();
File schemaFile = new File(schemaFileName);
writeSchemaToFile.setFailOnError(true);
writeSchemaToFile.setOutputFile(schemaFile);
WriteDataToFileCommand writeDataToFile = new WriteDataToFileCommand();
File dataFile = new File(dataFileName);
writeDataToFile.setFailOnError(true);
writeDataToFile.setOutputFile(dataFile);
fromDBTask.addWriteSchemaToFile(writeSchemaToFile);
fromDBTask.addWriteDataToFile(writeDataToFile);
fromDBTask.execute();
dataSource.close();
// end dump to XML
}
示例6: runImportExportTest_Import
import org.apache.commons.dbcp.BasicDataSource; //导入方法依赖的package包/类
static void runImportExportTest_Import(final Connection netConn,
final String clientUrl, final String userName, final String password,
final String schemaFileName, final String dataFileName) throws Throwable {
// now load the tables using the XML data
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName("com.pivotal.gemfirexd.jdbc.ClientDriver");
dataSource.setUrl("jdbc:gemfirexd://" + clientUrl);
if (userName != null) {
dataSource.setUsername(userName);
dataSource.setPassword(password);
}
DdlToDatabaseTask toDBTask = new DdlToDatabaseTask();
toDBTask.addConfiguredDatabase(dataSource);
File schemaFile = new File(schemaFileName);
toDBTask.setSchemaFile(schemaFile);
WriteSchemaToDatabaseCommand writeSchemaToDB =
new WriteSchemaToDatabaseCommand();
writeSchemaToDB.setAlterDatabase(true);
writeSchemaToDB.setFailOnError(true);
toDBTask.addWriteSchemaToDatabase(writeSchemaToDB);
toDBTask.execute();
WriteDataToDatabaseCommand writeDataToDB = new WriteDataToDatabaseCommand();
File dataFile = new File(dataFileName);
writeDataToDB.setIsolationLevel(Connection.TRANSACTION_READ_COMMITTED);
writeDataToDB.setUseBatchMode(true);
writeDataToDB.setBatchSize(1000);
writeDataToDB.setDataFile(dataFile);
writeDataToDB.setFailOnError(true);
// next check for the success case
toDBTask = new DdlToDatabaseTask();
toDBTask.addConfiguredDatabase(dataSource);
toDBTask.setSchemaFile(schemaFile);
toDBTask.addWriteDataToDatabase(writeDataToDB);
toDBTask.execute();
dataSource.close();
// end load the tables using the XML data
}
示例7: destroyInstance
import org.apache.commons.dbcp.BasicDataSource; //导入方法依赖的package包/类
@Override
protected void destroyInstance(BasicDataSource instance) throws Exception {
instance.close();
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:5,代码来源:GreenplumDataSourceFactoryBean.java