diff --git a/webapp/lib/commons-dbcp-1.2.1.jar b/webapp/lib/commons-dbcp-1.2.1.jar deleted file mode 100644 index 08440c02e..000000000 Binary files a/webapp/lib/commons-dbcp-1.2.1.jar and /dev/null differ diff --git a/webapp/lib/commons-dbcp-1.2.2.jar b/webapp/lib/commons-dbcp-1.2.2.jar deleted file mode 100644 index faea05626..000000000 Binary files a/webapp/lib/commons-dbcp-1.2.2.jar and /dev/null differ diff --git a/webapp/lib/commons-dbcp-1.4.jar b/webapp/lib/commons-dbcp-1.4.jar new file mode 100644 index 000000000..c4c1c4f28 Binary files /dev/null and b/webapp/lib/commons-dbcp-1.4.jar differ diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/SDBGraphGenerator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/SDBGraphGenerator.java index 11479df54..41e0f0c49 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/SDBGraphGenerator.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/SDBGraphGenerator.java @@ -28,21 +28,36 @@ public class SDBGraphGenerator implements GraphGenerator { this.storeDesc = storeDesc; this.graphID = graphID; } - - public Graph generateGraph() { - try { - if ( ( this.connection == null ) || ( this.connection.isClosed() ) ) { - 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 Graph generateGraph() { + try { + if ( this.connection == null ) { + this.connection = ds.getConnection(); + } else if ( this.connection.isClosed() ) { + try { + this.connection.close(); + } catch (SQLException e) { + // The connection will throw an "Already closed" + // SQLException that we need to catch. We need to + // 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() { return connection; }