• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PoolingDriver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.commons.dbcp2.PoolingDriver的典型用法代码示例。如果您正苦于以下问题:Java PoolingDriver类的具体用法?Java PoolingDriver怎么用?Java PoolingDriver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PoolingDriver类属于org.apache.commons.dbcp2包,在下文中一共展示了PoolingDriver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: shutdownDriver

import org.apache.commons.dbcp2.PoolingDriver; //导入依赖的package包/类
public static void shutdownDriver(String poolName) throws Exception {
	PoolingDriver driver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:");
	driver.closePool(poolName);
	
	if (ConnInfoList.containsKey(poolName)) {
		ConnInfoList.remove(poolName);
	}		
}
 
开发者ID:experdb,项目名称:eXperDB-DB2PG,代码行数:9,代码来源:DBCPPoolManager.java


示例2: shutdownAllDriver

import org.apache.commons.dbcp2.PoolingDriver; //导入依赖的package包/类
public static void shutdownAllDriver() {
	try {
		PoolingDriver driver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:");
		for (String poolName : driver.getPoolNames()) {
			driver.closePool(poolName);
			
			if (ConnInfoList.containsKey(poolName)) {
				ConnInfoList.remove(poolName);
			}	
		}
	}catch(Exception e){
		LogUtils.error(CommonUtil.getStackTrace(e), DBCPPoolManager.class);
	}
}
 
开发者ID:experdb,项目名称:eXperDB-DB2PG,代码行数:15,代码来源:DBCPPoolManager.java


示例3: serviceInit

import org.apache.commons.dbcp2.PoolingDriver; //导入依赖的package包/类
@Override
protected void serviceInit(Configuration conf) throws Exception {
    LOG.info("initialize service - " + getName());

    Class.forName("org.apache.commons.dbcp2.PoolingDriver");
    Class.forName("kr.co.bitnine.octopus.engine.calcite.Driver"); // FIXME:
    poolingDriver = (PoolingDriver) DriverManager.getDriver(DRIVER_PREFIX);

    super.serviceInit(conf);
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:11,代码来源:ConnectionManager.java


示例4: createConnectionPool

import org.apache.commons.dbcp2.PoolingDriver; //导入依赖的package包/类
private void createConnectionPool(String url, String user, String propertyKey,
    Properties properties) throws SQLException, ClassNotFoundException {
  ConnectionFactory connectionFactory =
    new DriverManagerConnectionFactory(url, properties);

  PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(
    connectionFactory, null);
  ObjectPool connectionPool = new GenericObjectPool(poolableConnectionFactory);

  poolableConnectionFactory.setPool(connectionPool);
  Class.forName(properties.getProperty(DRIVER_KEY));
  PoolingDriver driver = new PoolingDriver();
  driver.registerPool(propertyKey + user, connectionPool);
  getJDBCConfiguration(user).saveDBDriverPool(propertyKey, driver);
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:16,代码来源:JDBCInterpreter.java


示例5: setupDriver

import org.apache.commons.dbcp2.PoolingDriver; //导入依赖的package包/类
public static void setupDriver(String connectURI) throws Exception {
    //
    // First, we'll create a ConnectionFactory that the
    // pool will use to create Connections.
    // We'll use the DriverManagerConnectionFactory,
    // using the connect string passed in the command line
    // arguments.
    //
    ConnectionFactory connectionFactory =
        new DriverManagerConnectionFactory(connectURI,null);

    //
    // Next, we'll create the PoolableConnectionFactory, which wraps
    // the "real" Connections created by the ConnectionFactory with
    // the classes that implement the pooling functionality.
    //
    PoolableConnectionFactory poolableConnectionFactory =
        new PoolableConnectionFactory(connectionFactory, null);

    //
    // Now we'll need a ObjectPool that serves as the
    // actual pool of connections.
    //
    // We'll use a GenericObjectPool instance, although
    // any ObjectPool implementation will suffice.
    //
    ObjectPool<PoolableConnection> connectionPool =
        new GenericObjectPool<>(poolableConnectionFactory);
    
    // Set the factory's pool property to the owning pool
    poolableConnectionFactory.setPool(connectionPool);

    //
    // Finally, we create the PoolingDriver itself...
    //
    Class.forName("org.apache.commons.dbcp2.PoolingDriver");
    PoolingDriver driver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:");

    //
    // ...and register our pool with it.
    //
    driver.registerPool("example",connectionPool);

    //
    // Now we can just use the connect string "jdbc:apache:commons:dbcp:example"
    // to access our pool of Connections.
    //
}
 
开发者ID:apache,项目名称:commons-dbcp,代码行数:49,代码来源:PoolingDriverExample.java


示例6: printDriverStats

import org.apache.commons.dbcp2.PoolingDriver; //导入依赖的package包/类
public static void printDriverStats() throws Exception {
    PoolingDriver driver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:");
    ObjectPool<? extends Connection> connectionPool = driver.getConnectionPool("example");

    System.out.println("NumActive: " + connectionPool.getNumActive());
    System.out.println("NumIdle: " + connectionPool.getNumIdle());
}
 
开发者ID:apache,项目名称:commons-dbcp,代码行数:8,代码来源:PoolingDriverExample.java


示例7: getPoolingDriver

import org.apache.commons.dbcp2.PoolingDriver; //导入依赖的package包/类
private PoolingDriver getPoolingDriver() throws SQLException {
    final PoolingDriver driver = (PoolingDriver) DriverManager.getDriver(URL_PREFIX);
    if (driver == null) {
        getLogger().error("No JDBC driver for '{}'", URL_PREFIX);
    }
    return driver;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:8,代码来源:PoolingDriverConnectionSource.java


示例8: stop

import org.apache.commons.dbcp2.PoolingDriver; //导入依赖的package包/类
@Override
public boolean stop(long timeout, TimeUnit timeUnit) {
    try {
        final PoolingDriver driver = getPoolingDriver();
        if (driver != null) {
            getLogger().debug("Closing DBCP pool '{}'", poolName);
            driver.closePool(poolName);
        }
        return true;
    } catch (Exception e) {
        getLogger().error("Exception stopping connection source for '{}' → '{}'", getConnectionString(),
                getActualConnectionString(), e);
        return false;
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:16,代码来源:PoolingDriverConnectionSource.java


示例9: GetPoolNameList

import org.apache.commons.dbcp2.PoolingDriver; //导入依赖的package包/类
public static String[] GetPoolNameList() throws Exception {
	PoolingDriver driver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:");
	return driver.getPoolNames();
}
 
开发者ID:experdb,项目名称:eXperDB-DB2PG,代码行数:5,代码来源:DBCPPoolManager.java


示例10: shutdownDriver

import org.apache.commons.dbcp2.PoolingDriver; //导入依赖的package包/类
private static void shutdownDriver() throws Exception {
    PoolingDriver driver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:");
    driver.closePool(POOL_NAME);
}
 
开发者ID:odelarosa,项目名称:ZkPortal,代码行数:5,代码来源:DB.java


示例11: saveDBDriverPool

import org.apache.commons.dbcp2.PoolingDriver; //导入依赖的package包/类
public void saveDBDriverPool(String key, PoolingDriver driver) throws SQLException {
  poolingDriverMap.put(key, driver);
  isSuccessful.put(key, false);
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:5,代码来源:JDBCUserConfigurations.java


示例12: removeDBDriverPool

import org.apache.commons.dbcp2.PoolingDriver; //导入依赖的package包/类
public PoolingDriver removeDBDriverPool(String key) throws SQLException {
  isSuccessful.remove(key);
  return poolingDriverMap.remove(key);
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:5,代码来源:JDBCUserConfigurations.java


示例13: closeDBPool

import org.apache.commons.dbcp2.PoolingDriver; //导入依赖的package包/类
private void closeDBPool(String user, String propertyKey) throws SQLException {
  PoolingDriver poolingDriver = getJDBCConfiguration(user).removeDBDriverPool(propertyKey);
  if (poolingDriver != null) {
    poolingDriver.closePool(propertyKey + user);
  }
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:7,代码来源:JDBCInterpreter.java


示例14: shutdownDriver

import org.apache.commons.dbcp2.PoolingDriver; //导入依赖的package包/类
public static void shutdownDriver() throws Exception {
    PoolingDriver driver = (PoolingDriver) DriverManager.getDriver("jdbc:apache:commons:dbcp:");
    driver.closePool("example");
}
 
开发者ID:apache,项目名称:commons-dbcp,代码行数:5,代码来源:PoolingDriverExample.java


示例15: setupDriver

import org.apache.commons.dbcp2.PoolingDriver; //导入依赖的package包/类
private void setupDriver(final String connectionString) throws SQLException {
    //
    // First, we'll create a ConnectionFactory that the
    // pool will use to create Connections.
    // We'll use the DriverManagerConnectionFactory,
    // using the connect string passed in the command line
    // arguments.
    //
    final ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectionString, null);

    //
    // Next, we'll create the PoolableConnectionFactory, which wraps
    // the "real" Connections created by the ConnectionFactory with
    // the classes that implement the pooling functionality.
    //
    final PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,
            null);

    //
    // Now we'll need a ObjectPool that serves as the
    // actual pool of connections.
    //
    // We'll use a GenericObjectPool instance, although
    // any ObjectPool implementation will suffice.
    //
    @SuppressWarnings("resource")
    // This GenericObjectPool will be closed on shutown
    final ObjectPool<PoolableConnection> connectionPool = new GenericObjectPool<>(poolableConnectionFactory);

    // Set the factory's pool property to the owning pool
    poolableConnectionFactory.setPool(connectionPool);

    loadDriver(poolingDriverClassName);
    final PoolingDriver driver = getPoolingDriver();
    if (driver != null) {
        getLogger().debug("Registering DBCP pool '{}'", poolName);
        driver.registerPool(poolName, connectionPool);
    }
    //
    // Now we can just use the connect string "jdbc:apache:commons:dbcp:example"
    // to access our pool of Connections.
    //
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:44,代码来源:PoolingDriverConnectionSource.java



注:本文中的org.apache.commons.dbcp2.PoolingDriver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ModuleBuildTarget类代码示例发布时间:2022-05-23
下一篇:
Java FrameworkSupportInModuleConfigurable类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap