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

Java ViburDBCPDataSource类代码示例

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

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



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

示例1: testSelectStatementWithStatementsCache

import org.vibur.dbcp.ViburDBCPDataSource; //导入依赖的package包/类
@Test
public void testSelectStatementWithStatementsCache() throws SQLException {
    Session session = HibernateTestUtils.getSessionFactoryWithStmtCache().openSession();

    ConnectionProvider cp = ((SessionFactoryImplementor) session.getSessionFactory())
            .getServiceRegistry().getService(ConnectionProvider.class);
    ViburDBCPDataSource ds = ((ViburDBCPConnectionProvider) cp).getDataSource();

    ConcurrentMap<StatementMethod, StatementHolder> mockedStatementCache = mockStatementCache(ds);

    executeAndVerifySelectInSession(session);
    // resources/hibernate-with-stmt-cache.cfg.xml defines pool with 1 connection only, that's why
    // the second session will get and use the same underlying connection.
    session = HibernateTestUtils.getSessionFactoryWithStmtCache().openSession();
    executeAndVerifySelectInSession(session);

    InOrder inOrder = inOrder(mockedStatementCache);
    inOrder.verify(mockedStatementCache).get(key1.capture());
    inOrder.verify(mockedStatementCache).putIfAbsent(same(key1.getValue()), val1.capture());
    inOrder.verify(mockedStatementCache).get(key2.capture());

    assertEquals(1, mockedStatementCache.size());
    assertTrue(mockedStatementCache.containsKey(key1.getValue()));
    assertEquals(key1.getValue(), key2.getValue());
    assertEquals(AVAILABLE, val1.getValue().state().get());
}
 
开发者ID:vibur,项目名称:vibur-dbcp-hibernate4,代码行数:27,代码来源:ViburDBCPConnectionProviderTest.java


示例2: getInfo

import org.vibur.dbcp.ViburDBCPDataSource; //导入依赖的package包/类
@Override
public DataSourceInfo getInfo(final Object resource) throws Exception {
  DataSourceInfo dataSourceInfo = null;
  if (canMap(resource)) {
    ViburDBCPDataSource source = (ViburDBCPDataSource) resource;

    MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
    ObjectName poolName = new ObjectName(source.getJmxName());
    ViburMonitoringMBean poolProxy =
        JMX.newMXBeanProxy(mbeanServer, poolName, ViburMonitoringMBean.class);

    dataSourceInfo = new DataSourceInfo();
    dataSourceInfo.setBusyConnections(poolProxy.getPoolTaken());
    dataSourceInfo.setEstablishedConnections(
        poolProxy.getPoolRemainingCreated() + poolProxy.getPoolTaken());
    dataSourceInfo.setMaxConnections(source.getPoolMaxSize());
    dataSourceInfo.setJdbcUrl(source.getJdbcUrl());
    dataSourceInfo.setUsername(source.getUsername());
    dataSourceInfo.setResettable(false);
    dataSourceInfo.setType("vibur");
  }
  return dataSourceInfo;
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:24,代码来源:ViburCpDatasourceAccessor.java


示例3: testSelectStatementWithStatementsCache

import org.vibur.dbcp.ViburDBCPDataSource; //导入依赖的package包/类
@Test
public void testSelectStatementWithStatementsCache() throws SQLException {
    Session session = HibernateTestUtils.getSessionFactoryWithStmtCache().openSession();

    ConnectionProvider cp = ((SessionFactoryImplementor) session.getSessionFactory()).getConnectionProvider();
    ViburDBCPDataSource ds = ((ViburDBCPConnectionProvider) cp).getDataSource();

    ConcurrentMap<StatementMethod, StatementHolder> mockedStatementCache = mockStatementCache(ds);

    executeAndVerifySelectInSession(session);
    // resources/hibernate-with-stmt-cache.cfg.xml defines pool with 1 connection only, that's why
    // the second session will get and use the same underlying connection.
    session = HibernateTestUtils.getSessionFactoryWithStmtCache().openSession();
    executeAndVerifySelectInSession(session);

    InOrder inOrder = inOrder(mockedStatementCache);
    inOrder.verify(mockedStatementCache).get(key1.capture());
    inOrder.verify(mockedStatementCache).putIfAbsent(same(key1.getValue()), val1.capture());
    inOrder.verify(mockedStatementCache).get(key2.capture());

    assertEquals(1, mockedStatementCache.size());
    assertTrue(mockedStatementCache.containsKey(key1.getValue()));
    assertEquals(key1.getValue(), key2.getValue());
    assertEquals(AVAILABLE, val1.getValue().state().get());
}
 
开发者ID:vibur,项目名称:vibur-dbcp-hibernate3,代码行数:26,代码来源:ViburDBCPConnectionProviderTest.java


示例4: getViburDataSourceWithDriverClassName

import org.vibur.dbcp.ViburDBCPDataSource; //导入依赖的package包/类
private static DataSource getViburDataSourceWithDriverClassName() {
    ViburDBCPDataSource ds = new ViburDBCPDataSource();

    ds.setJdbcUrl(URL + ";TEST=VIBUR_WITH_CLASSNAME");
    ds.setPoolInitialSize(3);
    ds.setPoolMaxSize(10);
    ds.setTestConnectionQuery("SELECT 1");
    ds.setDriverClassName(ContainerDatabaseDriver.class.getName());

    ds.start();

    return ds;
}
 
开发者ID:testcontainers,项目名称:testcontainers-java,代码行数:14,代码来源:JDBCDriverWithPoolTest.java


示例5: getViburDataSource

import org.vibur.dbcp.ViburDBCPDataSource; //导入依赖的package包/类
private static DataSource getViburDataSource() {
    ViburDBCPDataSource ds = new ViburDBCPDataSource();
    ds.setJdbcUrl(URL + ";TEST=VIBUR");
    ds.setPoolInitialSize(3);
    ds.setPoolMaxSize(10);
    ds.setTestConnectionQuery("SELECT 1");

    ds.start();

    return ds;
}
 
开发者ID:testcontainers,项目名称:testcontainers-java,代码行数:12,代码来源:JDBCDriverWithPoolTest.java


示例6: PoolOperations

import org.vibur.dbcp.ViburDBCPDataSource; //导入依赖的package包/类
/**
 * Instantiates the PoolOperations facade.
 *
 * @param dataSource the Vibur dataSource on which we will operate
 * @param connectionFactory the Vibur connection factory
 * @param poolService the Vibur pool service
 */
public PoolOperations(ViburDBCPDataSource dataSource, ViburObjectFactory connectionFactory, PoolService<ConnHolder> poolService) {
    this.dataSource = dataSource;
    this.connectionTimeoutInNanos = MILLISECONDS.toNanos(dataSource.getConnectionTimeoutInMs());
    this.connectionFactory = connectionFactory;
    this.poolService = poolService;
    this.criticalSQLStates = new HashSet<>(Arrays.asList(
            whitespaces.matcher(dataSource.getCriticalSQLStates()).replaceAll("").split(",")));
}
 
开发者ID:vibur,项目名称:vibur-dbcp,代码行数:16,代码来源:PoolOperations.java


示例7: Worker

import org.vibur.dbcp.ViburDBCPDataSource; //导入依赖的package包/类
private Worker(ViburDBCPDataSource ds, AtomicInteger errors, long millis,
               CountDownLatch readySignal, CountDownLatch startSignal, CountDownLatch doneSignal) {
    this.ds = ds;
    this.errors = errors;
    this.millis = millis;
    this.startSignal = startSignal;
    this.readySignal = readySignal;
    this.doneSignal = doneSignal;
}
 
开发者ID:vibur,项目名称:vibur-dbcp,代码行数:10,代码来源:ViburDBCPGetConnectionTestPerf.java


示例8: createDataSource

import org.vibur.dbcp.ViburDBCPDataSource; //导入依赖的package包/类
private static ViburDBCPDataSource createDataSource() {
    ViburDBCPDataSource ds = new ViburDBCPDataSource();
    ds.setJdbcUrl("jdbc:hsqldb:mem:sakila;shutdown=false");
    ds.setUsername("sa");
    ds.setPassword("");

    ds.setPoolInitialSize(INITIAL_SIZE);
    ds.setPoolMaxSize(MAX_SIZE);
    ds.setConnectionTimeoutInMs(TIMEOUT_MS);
    ds.setPoolFair(FAIR);
    return ds;
}
 
开发者ID:vibur,项目名称:vibur-dbcp,代码行数:13,代码来源:ViburDBCPGetConnectionTestPerf.java


示例9: configuration

import org.vibur.dbcp.ViburDBCPDataSource; //导入依赖的package包/类
@Bean
public Configuration<ViburDBCPDataSource> configuration() {
    return new Configuration.Builder<ViburDBCPDataSource>(
            uniqueId,
            poolingDataSource,
            ViburDBCPPoolAdapter.FACTORY
    ).build();
}
 
开发者ID:vladmihalcea,项目名称:flexy-pool,代码行数:9,代码来源:FlexyPoolConfiguration.java


示例10: dataSource

import org.vibur.dbcp.ViburDBCPDataSource; //导入依赖的package包/类
@Bean(initMethod = "start", destroyMethod = "stop")
public FlexyPoolDataSource dataSource() {
    Configuration<ViburDBCPDataSource> configuration = configuration();
    return new FlexyPoolDataSource<ViburDBCPDataSource>(configuration,
            new RetryConnectionAcquiringStrategy.Factory(2)
    );
}
 
开发者ID:vladmihalcea,项目名称:flexy-pool,代码行数:8,代码来源:FlexyPoolConfiguration.java


示例11: configure

import org.vibur.dbcp.ViburDBCPDataSource; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void configure(Map configurationValues) {
    dataSource = new ViburDBCPDataSource(transform(configurationValues));
    dataSource.start();
}
 
开发者ID:vibur,项目名称:vibur-dbcp-hibernate4.012,代码行数:7,代码来源:ViburDBCPConnectionProvider.java


示例12: getDataSource

import org.vibur.dbcp.ViburDBCPDataSource; //导入依赖的package包/类
public ViburDBCPDataSource getDataSource() {
    return dataSource;
}
 
开发者ID:vibur,项目名称:vibur-dbcp-hibernate4.012,代码行数:4,代码来源:ViburDBCPConnectionProvider.java


示例13: canMap

import org.vibur.dbcp.ViburDBCPDataSource; //导入依赖的package包/类
@Override
public boolean canMap(final Object resource) {
  return "org.vibur.dbcp.ViburDBCPDataSource".equals(resource.getClass().getName())
      && resource instanceof ViburDBCPDataSource;
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:6,代码来源:ViburCpDatasourceAccessor.java


示例14: configure

import org.vibur.dbcp.ViburDBCPDataSource; //导入依赖的package包/类
@Override
public void configure(Properties props) throws HibernateException {
    dataSource = new ViburDBCPDataSource(transform(props));
    dataSource.start();
}
 
开发者ID:vibur,项目名称:vibur-dbcp-hibernate3,代码行数:6,代码来源:ViburDBCPConnectionProvider.java


示例15: newInstance

import org.vibur.dbcp.ViburDBCPDataSource; //导入依赖的package包/类
@Override
public PoolAdapter<ViburDBCPDataSource> newInstance(
        ConfigurationProperties<ViburDBCPDataSource, Metrics, PoolAdapter<ViburDBCPDataSource>> configurationProperties) {
    return new ViburDBCPPoolAdapter(configurationProperties);
}
 
开发者ID:vladmihalcea,项目名称:flexy-pool,代码行数:6,代码来源:ViburDBCPPoolAdapter.java


示例16: ViburDBCPPoolAdapter

import org.vibur.dbcp.ViburDBCPDataSource; //导入依赖的package包/类
/**
 * Init constructor
 * @param configurationProperties configuration properties
 */
public ViburDBCPPoolAdapter(ConfigurationProperties<ViburDBCPDataSource, Metrics, PoolAdapter<ViburDBCPDataSource>> configurationProperties) {
    super(configurationProperties);
}
 
开发者ID:vladmihalcea,项目名称:flexy-pool,代码行数:8,代码来源:ViburDBCPPoolAdapter.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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