[PATCH] Connection pool: do not wait forever for new connections and be more verbose
Wald Commits
scm-commit at wald.intevation.org
Thu Nov 27 19:56:35 CET 2014
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1417114555 -3600
# Node ID 7dd39219bd68f9311c7054c02ca1b90a7367210e
# Parent 3cfa0af6fa2a2c926cb51cb6aa5fc22ec0af3a80
Connection pool: do not wait forever for new connections and be more verbose.
diff -r 3cfa0af6fa2a -r 7dd39219bd68 backend/src/main/java/org/dive4elements/river/backend/utils/DBCPConnectionProvider.java
--- a/backend/src/main/java/org/dive4elements/river/backend/utils/DBCPConnectionProvider.java Thu Nov 27 19:14:05 2014 +0100
+++ b/backend/src/main/java/org/dive4elements/river/backend/utils/DBCPConnectionProvider.java Thu Nov 27 19:55:55 2014 +0100
@@ -215,6 +215,7 @@
String validationQuery = props.getProperty("validationQuery");
if (validationQuery != null) {
ds.setValidationQuery(validationQuery);
+ ds.setMaxWait(1000); //TODO: make it configurable
}
// The BasicDataSource has lazy initialization
// borrowing a connection will start the DataSource
@@ -240,10 +241,20 @@
}
public Connection getConnection() throws SQLException {
- return ds.getConnection();
+ log.debug("Connection pool parameters:");
+ log.debug("_ active connections: " + ds.getNumActive());
+ log.debug("_ idle connections: " + ds.getNumIdle());
+ log.debug("_ max active: " + ds.getMaxActive());
+ if (ds.getNumActive() == ds.getMaxActive()) {
+ log.warn("Maximum number of database connections in pool in use!");
+ }
+ Connection conn = ds.getConnection();
+ log.debug("Return connection with hash: " + conn.hashCode());
+ return conn;
}
public void closeConnection(Connection conn) throws SQLException {
+ log.debug("Close connection with hash: " + conn.hashCode());
conn.close();
}
More information about the Dive4Elements-commits
mailing list