NIHVIVO-2576 addresses issue with db connections closed by MySQL not being returned to the pool
This commit is contained in:
parent
6363b3fb11
commit
2f132d6290
4 changed files with 30 additions and 15 deletions
Binary file not shown.
Binary file not shown.
BIN
webapp/lib/commons-dbcp-1.4.jar
Normal file
BIN
webapp/lib/commons-dbcp-1.4.jar
Normal file
Binary file not shown.
|
@ -29,19 +29,34 @@ public class SDBGraphGenerator implements GraphGenerator {
|
||||||
this.graphID = graphID;
|
this.graphID = graphID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Graph generateGraph() {
|
public Graph generateGraph() {
|
||||||
try {
|
try {
|
||||||
if ( ( this.connection == null ) || ( this.connection.isClosed() ) ) {
|
if ( this.connection == null ) {
|
||||||
this.connection = ds.getConnection();
|
this.connection = ds.getConnection();
|
||||||
}
|
} else if ( this.connection.isClosed() ) {
|
||||||
Store store = SDBFactory.connectStore(connection, storeDesc);
|
try {
|
||||||
return SDBFactory.connectNamedGraph(store, graphID);
|
this.connection.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
String errMsg = "Unable to generate SDB graph";
|
// The connection will throw an "Already closed"
|
||||||
log.error(errMsg, e);
|
// SQLException that we need to catch. We need to
|
||||||
throw new RuntimeException(errMsg, e);
|
// make this extra call to .close() in order to make
|
||||||
}
|
// sure that the connection is returned to the pool.
|
||||||
}
|
// This depends on the particular behavior of version
|
||||||
|
// 1.4 of the Apache Commons connection pool library.
|
||||||
|
// Earlier versions threw the exception right away,
|
||||||
|
// making this impossible. Future versions may do the
|
||||||
|
// same.
|
||||||
|
}
|
||||||
|
this.connection = ds.getConnection();
|
||||||
|
}
|
||||||
|
Store store = SDBFactory.connectStore(connection, storeDesc);
|
||||||
|
return SDBFactory.connectNamedGraph(store, graphID);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String errMsg = "Unable to generate SDB graph";
|
||||||
|
log.error(errMsg, e);
|
||||||
|
throw new RuntimeException(errMsg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Connection getConnection() {
|
public Connection getConnection() {
|
||||||
return connection;
|
return connection;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue