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