From 0a4262d87652874552070e7fda4c0a03c6f952b1 Mon Sep 17 00:00:00 2001 From: brianjlowe Date: Fri, 31 Aug 2012 15:14:04 +0000 Subject: [PATCH] enabling connection testing with C3P0 --- .../mannlib/vitro/webapp/dao/jena/RDBGraphGenerator.java | 6 +++--- .../vitro/webapp/servlet/setup/JenaDataSourceSetupBase.java | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDBGraphGenerator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDBGraphGenerator.java index 9d3ed7b6f..4f24a3009 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDBGraphGenerator.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDBGraphGenerator.java @@ -42,15 +42,15 @@ public class RDBGraphGenerator implements SQLGraphGenerator { } public Graph generateGraph() { - log.info("Regenerate the graph."); try { // if (log.isDebugEnabled()) { // log.debug(ds.getNumActive() + " active SQL connections"); // log.debug(ds.getNumIdle() + " idle SQL connections"); // } - if ( ( this.connection == null ) || ( this.connection.isClosed() ) ) { - this.connection = ds.getConnection(); + if ( ( this.connection != null ) && ( !this.connection.isClosed() ) ) { + this.connection.close(); } + this.connection = ds.getConnection(); IDBConnection idbConn = new DBConnection(this.connection, dbTypeStr); Graph requestedProperties = null; boolean modelExists = idbConn.containsModel(graphID); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetupBase.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetupBase.java index 8ddf0b6a5..46958132c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetupBase.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetupBase.java @@ -244,6 +244,9 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon { cpds.setMaxIdleTimeExcessConnections(300); cpds.setAcquireIncrement(5); cpds.setNumHelperThreads(6); + cpds.setTestConnectionOnCheckout(DEFAULT_TESTONBORROW); + cpds.setTestConnectionOnCheckin(DEFAULT_TESTONRETURN); + cpds.setPreferredTestQuery(getValidationQuery(ctx)); return cpds; }