本文整理汇总了Java中com.alibaba.druid.pool.DruidDataSource.close方法的典型用法代码示例。如果您正苦于以下问题:Java DruidDataSource.close方法的具体用法?Java DruidDataSource.close怎么用?Java DruidDataSource.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.druid.pool.DruidDataSource
的用法示例。
在下文中一共展示了DruidDataSource.close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testJDBC
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
@Test
public void testJDBC() throws Exception {
Properties properties = new Properties();
properties.put("url", "jdbc:elasticsearch://127.0.0.1:9300/" + TestsConstants.TEST_INDEX);
DruidDataSource dds = (DruidDataSource) ElasticSearchDruidDataSourceFactory.createDataSource(properties);
Connection connection = dds.getConnection();
PreparedStatement ps = connection.prepareStatement("SELECT gender,lastname,age from " + TestsConstants.TEST_INDEX + " where lastname='Heath'");
ResultSet resultSet = ps.executeQuery();
List<String> result = new ArrayList<String>();
while (resultSet.next()) {
result.add(resultSet.getString("lastname") + "," + resultSet.getInt("age") + "," + resultSet.getString("gender"));
}
ps.close();
connection.close();
dds.close();
Assert.assertTrue(result.size()==1);
Assert.assertTrue(result.get(0).equals("Heath,39,F"));
}
示例2: shutdown
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
@Override
public void shutdown() {
if (sqlSessionFactory != null) {
DruidDataSource druidDataSource = (DruidDataSource) sqlSessionFactory.getConfiguration().getEnvironment().getDataSource();
druidDataSource.close();
sqlSessionFactory = null;
}
}
示例3: close
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
public void close() {
logger.debug("销毁 DynamicDataSource {}...",this.dataSourceName);
this.masterDataSource.close();
Iterator<DruidDataSource> it = this.slaveDataSources.values().iterator();
while (it.hasNext()) {
DruidDataSource druidDataSource = (DruidDataSource) it.next();
try {
druidDataSource.close();
} catch (Exception e) {
logger.warn("关闭从库{}失败", druidDataSource.getName());
}
}
}
示例4: closeDruidDataSource
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
/**
* Close druid data source.
*
* @param dataSource dataSource
*/
public static void closeDruidDataSource(DruidDataSource dataSource) {
if (dataSource != null) {
dataSource.close();
}
}