Search in sources :

Example 1 with ViburDBCPDataSource

use of org.vibur.dbcp.ViburDBCPDataSource in project testcontainers-java by testcontainers.

the class JDBCDriverWithPoolTest method getViburDataSourceWithDriverClassName.

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;
}
Also used : ViburDBCPDataSource(org.vibur.dbcp.ViburDBCPDataSource)

Example 2 with ViburDBCPDataSource

use of org.vibur.dbcp.ViburDBCPDataSource in project hibernate-orm by hibernate.

the class ViburDBCPConnectionProvider method configure.

@Override
public void configure(Map<String, Object> configurationValues) {
    dataSource = new ViburDBCPDataSource(transform(configurationValues));
    dataSource.start();
}
Also used : ViburDBCPDataSource(org.vibur.dbcp.ViburDBCPDataSource)

Example 3 with ViburDBCPDataSource

use of org.vibur.dbcp.ViburDBCPDataSource in project hibernate-orm by hibernate.

the class ViburDBCPConnectionProviderTest method testSelectStatementWithStatementsCache.

@Test
public void testSelectStatementWithStatementsCache() {
    setUpPoolAndDatabase(1, 10);
    ConnectionProvider cp = sessionFactory().getServiceRegistry().getService(ConnectionProvider.class);
    ViburDBCPDataSource ds = ((ViburDBCPConnectionProvider) cp).getDataSource();
    ConcurrentMap<StatementMethod, StatementHolder> mockedStatementCache = mockStatementCache(ds);
    doInHibernate(this::sessionFactory, ViburDBCPConnectionProviderTest::executeAndVerifySelect);
    // We set above the poolMaxSize = 1, that's why the second session will get and use the same underlying connection.
    doInHibernate(this::sessionFactory, ViburDBCPConnectionProviderTest::executeAndVerifySelect);
    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());
}
Also used : InOrder(org.mockito.InOrder) StatementMethod(org.vibur.dbcp.stcache.StatementMethod) ViburDBCPDataSource(org.vibur.dbcp.ViburDBCPDataSource) StatementHolder(org.vibur.dbcp.stcache.StatementHolder) ViburDBCPConnectionProvider(org.hibernate.vibur.internal.ViburDBCPConnectionProvider) ViburDBCPConnectionProvider(org.hibernate.vibur.internal.ViburDBCPConnectionProvider) ConnectionProvider(org.hibernate.engine.jdbc.connections.spi.ConnectionProvider) Test(org.junit.Test)

Example 4 with ViburDBCPDataSource

use of org.vibur.dbcp.ViburDBCPDataSource in project apm-agent-java by elastic.

the class DataSourceIT method getViburDataSource.

private static DataSource getViburDataSource() {
    ViburDBCPDataSource ds = new ViburDBCPDataSource();
    ds.setJdbcUrl(URL);
    ds.setUsername("");
    ds.setPassword("");
    ds.start();
    return ds;
}
Also used : ViburDBCPDataSource(org.vibur.dbcp.ViburDBCPDataSource)

Example 5 with ViburDBCPDataSource

use of org.vibur.dbcp.ViburDBCPDataSource in project testcontainers-java by testcontainers.

the class JDBCDriverWithPoolTest method getViburDataSource.

private static DataSource getViburDataSource() {
    ViburDBCPDataSource ds = new ViburDBCPDataSource();
    ds.setJdbcUrl(URL + ";TEST=VIBUR");
    // Recent versions of Vibur require a username, even though it will not be used
    ds.setUsername("any");
    ds.setPassword("");
    ds.setPoolInitialSize(3);
    ds.setPoolMaxSize(10);
    ds.setTestConnectionQuery("SELECT 1");
    ds.start();
    return ds;
}
Also used : ViburDBCPDataSource(org.vibur.dbcp.ViburDBCPDataSource)

Aggregations

ViburDBCPDataSource (org.vibur.dbcp.ViburDBCPDataSource)11 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 MBeanServer (javax.management.MBeanServer)1 ObjectName (javax.management.ObjectName)1 ConnectionProvider (org.hibernate.engine.jdbc.connections.spi.ConnectionProvider)1 ViburDBCPConnectionProvider (org.hibernate.vibur.internal.ViburDBCPConnectionProvider)1 Test (org.junit.Test)1 InOrder (org.mockito.InOrder)1 ContainerDatabaseDriver (org.testcontainers.jdbc.ContainerDatabaseDriver)1 ViburMonitoringMBean (org.vibur.dbcp.ViburMonitoringMBean)1 StatementHolder (org.vibur.dbcp.stcache.StatementHolder)1 StatementMethod (org.vibur.dbcp.stcache.StatementMethod)1 DataSourceInfo (psiprobe.model.DataSourceInfo)1