Replace c3p0 with dbcp2, so there is only one pooling library in use
This commit is contained in:
parent
6cbdcd6842
commit
4543e65d08
3 changed files with 31 additions and 32 deletions
|
@ -26,7 +26,7 @@ import org.apache.jena.sdb.sql.SDBConnection;
|
||||||
import org.apache.jena.sdb.store.DatabaseType;
|
import org.apache.jena.sdb.store.DatabaseType;
|
||||||
import org.apache.jena.sdb.store.LayoutType;
|
import org.apache.jena.sdb.store.LayoutType;
|
||||||
import org.apache.jena.sdb.util.StoreUtils;
|
import org.apache.jena.sdb.util.StoreUtils;
|
||||||
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset;
|
||||||
|
@ -86,7 +86,7 @@ public class ContentTripleSourceSDB extends ContentTripleSource {
|
||||||
static final boolean DEFAULT_TESTONRETURN = true;
|
static final boolean DEFAULT_TESTONRETURN = true;
|
||||||
|
|
||||||
private ServletContext ctx;
|
private ServletContext ctx;
|
||||||
private ComboPooledDataSource ds;
|
private BasicDataSource ds;
|
||||||
private RDFServiceFactory rdfServiceFactory;
|
private RDFServiceFactory rdfServiceFactory;
|
||||||
private RDFService rdfService;
|
private RDFService rdfService;
|
||||||
private Dataset dataset;
|
private Dataset dataset;
|
||||||
|
@ -233,12 +233,16 @@ public class ContentTripleSourceSDB extends ContentTripleSource {
|
||||||
this.rdfService.close();
|
this.rdfService.close();
|
||||||
}
|
}
|
||||||
if (ds != null) {
|
if (ds != null) {
|
||||||
String driverClassName = ds.getDriverClass();
|
String driverClassName = ds.getDriverClassName();
|
||||||
|
try {
|
||||||
ds.close();
|
ds.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
}finally {
|
||||||
attemptToDeregisterJdbcDriver(driverClassName);
|
attemptToDeregisterJdbcDriver(driverClassName);
|
||||||
cleanupAbandonedConnectionThread(driverClassName);
|
cleanupAbandonedConnectionThread(driverClassName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void attemptToDeregisterJdbcDriver(String driverClassName) {
|
private void attemptToDeregisterJdbcDriver(String driverClassName) {
|
||||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||||
|
|
||||||
|
@ -48,26 +48,26 @@ public class SDBDataSource {
|
||||||
this.configProps = ConfigurationProperties.getBean(ctx);
|
this.configProps = ConfigurationProperties.getBean(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComboPooledDataSource getDataSource() {
|
public BasicDataSource getDataSource() {
|
||||||
try {
|
BasicDataSource cpds = new BasicDataSource();
|
||||||
ComboPooledDataSource cpds = new ComboPooledDataSource();
|
cpds.setDriverClassName(getDbDriverClassName());
|
||||||
cpds.setDriverClass(getDbDriverClassName());
|
cpds.setUrl(getJdbcUrl());
|
||||||
cpds.setJdbcUrl(getJdbcUrl());
|
cpds.setUsername(configProps.getProperty(PROPERTY_DB_USERNAME));
|
||||||
cpds.setUser(configProps.getProperty(PROPERTY_DB_USERNAME));
|
|
||||||
cpds.setPassword(configProps.getProperty(PROPERTY_DB_PASSWORD));
|
cpds.setPassword(configProps.getProperty(PROPERTY_DB_PASSWORD));
|
||||||
cpds.setMaxPoolSize(getMaxActive());
|
cpds.setMaxTotal(getMaxActive());
|
||||||
cpds.setMinPoolSize(getMaxIdle());
|
cpds.setMaxIdle(getMaxIdle());
|
||||||
cpds.setMaxIdleTime(getMaxIdleTime());
|
cpds.setMinEvictableIdleTimeMillis(getMaxIdleTime());
|
||||||
cpds.setMaxIdleTimeExcessConnections(getMaxIdleTimeExcess());
|
cpds.setTestOnBorrow(DEFAULT_TESTONBORROW);
|
||||||
cpds.setAcquireIncrement(5);
|
cpds.setTestOnReturn(DEFAULT_TESTONRETURN);
|
||||||
cpds.setNumHelperThreads(6);
|
cpds.setValidationQuery(getValidationQuery());
|
||||||
cpds.setTestConnectionOnCheckout(DEFAULT_TESTONBORROW);
|
|
||||||
cpds.setTestConnectionOnCheckin(DEFAULT_TESTONRETURN);
|
|
||||||
cpds.setPreferredTestQuery(getValidationQuery());
|
|
||||||
return cpds;
|
return cpds;
|
||||||
} catch (PropertyVetoException pve) {
|
// try {
|
||||||
throw new RuntimeException(pve);
|
// cpds.setMaxIdleTimeExcessConnections(getMaxIdleTimeExcess());
|
||||||
}
|
// cpds.setAcquireIncrement(5);
|
||||||
|
// cpds.setNumHelperThreads(6);
|
||||||
|
// } catch (PropertyVetoException pve) {
|
||||||
|
// throw new RuntimeException(pve);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDbDriverClassName() {
|
private String getDbDriverClassName() {
|
||||||
|
|
5
dependencies/pom.xml
vendored
5
dependencies/pom.xml
vendored
|
@ -70,11 +70,6 @@
|
||||||
<artifactId>icu4j</artifactId>
|
<artifactId>icu4j</artifactId>
|
||||||
<version>3.4.4</version>
|
<version>3.4.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.mchange</groupId>
|
|
||||||
<artifactId>c3p0</artifactId>
|
|
||||||
<version>0.9.5.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
<artifactId>imageio-jpeg</artifactId>
|
<artifactId>imageio-jpeg</artifactId>
|
||||||
|
|
Loading…
Add table
Reference in a new issue