Search in sources :

Example 1 with JdbcDsLogRuntimeException

use of org.jdbcdslog.JdbcDsLogRuntimeException in project invesdwin-context-persistence by subes.

the class ConfiguredCPDataSource method createDelegate.

@Override
protected DataSource createDelegate() {
    final ComboPooledDataSource ds = new ComboPooledDataSource();
    try {
        ds.setDriverClass(context.getConnectionDriver());
    } catch (final PropertyVetoException e1) {
        throw Err.process(e1);
    }
    ds.setJdbcUrl(context.getConnectionUrl());
    ds.setUser(context.getConnectionUser());
    ds.setPassword(context.getConnectionPassword());
    ds.setMaxStatements(5000);
    ds.setMaxStatementsPerConnection(50);
    // fix apparent deadlocks
    ds.setStatementCacheNumDeferredCloseThreads(1);
    ds.setMaxPoolSize(100);
    ds.setMinPoolSize(1);
    ds.setMaxIdleTime(new Duration(1, FTimeUnit.MINUTES).intValue(FTimeUnit.SECONDS));
    ds.setTestConnectionOnCheckout(true);
    ds.setAutoCommitOnClose(true);
    Assertions.assertThat(this.closeableDs).isNull();
    this.closeableDs = ds;
    if (logging) {
        try {
            final ConnectionPoolDataSourceProxy proxy = new ConnectionPoolDataSourceProxy();
            proxy.setTargetDSDirect(ds);
            return proxy;
        } catch (final JdbcDsLogRuntimeException e) {
            throw new RuntimeException(e);
        }
    } else {
        return ds;
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource) JdbcDsLogRuntimeException(org.jdbcdslog.JdbcDsLogRuntimeException) Duration(de.invesdwin.util.time.duration.Duration) ConnectionPoolDataSourceProxy(org.jdbcdslog.ConnectionPoolDataSourceProxy) JdbcDsLogRuntimeException(org.jdbcdslog.JdbcDsLogRuntimeException)

Aggregations

ComboPooledDataSource (com.mchange.v2.c3p0.ComboPooledDataSource)1 Duration (de.invesdwin.util.time.duration.Duration)1 PropertyVetoException (java.beans.PropertyVetoException)1 ConnectionPoolDataSourceProxy (org.jdbcdslog.ConnectionPoolDataSourceProxy)1 JdbcDsLogRuntimeException (org.jdbcdslog.JdbcDsLogRuntimeException)1