Search in sources :

Example 26 with PoolProperties

use of org.apache.tomcat.jdbc.pool.PoolProperties in project oc-explorer by devgateway.

the class DatabaseConfiguration method dataSource.

/**
 * Creates a {@link javax.sql.DataSource} based on Tomcat {@link DataSource}
 *
 * @return
 */
@Bean
@DependsOn(value = { "derbyServer" })
public DataSource dataSource() {
    PoolProperties pp = new PoolProperties();
    pp.setJmxEnabled(true);
    pp.setDefaultTransactionIsolation(springDatasourceTransactionIsolation);
    pp.setInitialSize(springDatasourceInitialSize);
    pp.setMaxActive(springDatasourceMaxActive);
    DataSource dataSource = new DataSource(pp);
    dataSource.setUrl(springDatasourceUrl);
    dataSource.setUsername(springDatasourceUsername);
    dataSource.setPassword(springDatasourcePassword);
    dataSource.setDriverClassName(springDatasourceDriverClassName);
    return dataSource;
}
Also used : PoolProperties(org.apache.tomcat.jdbc.pool.PoolProperties) DataSource(org.apache.tomcat.jdbc.pool.DataSource) DependsOn(org.springframework.context.annotation.DependsOn) Bean(org.springframework.context.annotation.Bean)

Aggregations

PoolProperties (org.apache.tomcat.jdbc.pool.PoolProperties)26 DataSource (org.apache.tomcat.jdbc.pool.DataSource)10 Test (org.junit.Test)10 Connection (java.sql.Connection)6 DefaultProperties (org.apache.tomcat.jdbc.test.DefaultProperties)5 Properties (java.util.Properties)4 PoolConfiguration (org.apache.tomcat.jdbc.pool.PoolConfiguration)4 ResultSet (java.sql.ResultSet)3 Statement (java.sql.Statement)3 DataSource (javax.sql.DataSource)3 InterceptorDefinition (org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorDefinition)3 TrapException (org.apache.tomcat.jdbc.pool.TrapException)3 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 ConnectionPool (org.apache.tomcat.jdbc.pool.ConnectionPool)2 InterceptorProperty (org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty)2