r10001 - apps/modules/trunk/helma

[email protected] Mon, 30 Nov 2009 15:42:25 +0100 (CET)
Newsgroups gmane.comp.java.helma.cvs
Message-ID <20091130144225.4B6F93D0E2@mia>
Author: hannes
Date: 2009-11-30 15:42:24 +0100 (Mon, 30 Nov 2009)
New Revision: 10001

Modified:
   apps/modules/trunk/helma/Database.js
Log:
Do not cache connection in helma.Database as it is cached and validated already by helma.objectmodel.db code.

Details at http://dev.helma.org/trac/helma/changeset/10001

Modified: apps/modules/trunk/helma/Database.js
===================================================================
--- apps/modules/trunk/helma/Database.js	2009-11-30 10:58:34 UTC (rev 10000)
+++ apps/modules/trunk/helma/Database.js	2009-11-30 14:42:24 UTC (rev 10001)
@@ -59,8 +59,6 @@
     if (!(source instanceof DbSource))
         throw "helma.Database requires a helma.objectmodel.db.DbSource argument";
 
-    var connection = source.getConnection();
-
     /**
      * Get the java.sql.Connection for this Database instance. This can be used
      * to operate on the connection directly, without going through the helma.Database
@@ -68,7 +66,7 @@
      * @return {java.sql.Connection} the JDBC connection
      */
     this.getConnection = function() {
-        return connection;
+        return source.getConnection();
     };
 
     /**
@@ -76,7 +74,7 @@
      * @return {String} the name of the DB product
      */
     this.getProductName = function() {
-        return connection.getMetaData().getDatabaseProductName().toLowerCase();
+        return source.getConnection().getMetaData().getDatabaseProductName().toLowerCase();
     };
 
     /**
@@ -112,6 +110,7 @@
     this.query = function(sql) {
         var isLogSqlEnabled = (getProperty("logSQL", "false").toLowerCase() == "true");
         var logTimeStart = isLogSqlEnabled ? java.lang.System.currentTimeMillis() : 0;
+        var connection = source.getConnection();
         connection.setReadOnly(true);
         var statement = connection.createStatement();
         var resultSet = statement.executeQuery(sql);
@@ -194,6 +193,7 @@
     this.execute = function(sql) {
         var isLogSqlEnabled = (getProperty("logSQL", "false").toLowerCase() == "true");
         var logTimeStart = isLogSqlEnabled ? java.lang.System.currentTimeMillis() : 0;
+        var connection = source.getConnection();
         connection.setReadOnly(false);
         var statement = connection.createStatement();
         var result;