cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r164373 - /cocoon/blocks/unsupported/petstore/trunk/java/org/apache/cocoon/components/flow/javascript/ScriptableConnection.java
Date Sat, 23 Apr 2005 11:38:36 GMT
Author: antonio
Date: Sat Apr 23 04:38:34 2005
New Revision: 164373

URL: http://svn.apache.org/viewcvs?rev=164373&view=rev
Log:
Merging from 2.1.x. Fix bug 30326

Modified:
    cocoon/blocks/unsupported/petstore/trunk/java/org/apache/cocoon/components/flow/javascript/ScriptableConnection.java

Modified: cocoon/blocks/unsupported/petstore/trunk/java/org/apache/cocoon/components/flow/javascript/ScriptableConnection.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/unsupported/petstore/trunk/java/org/apache/cocoon/components/flow/javascript/ScriptableConnection.java?rev=164373&r1=164372&r2=164373&view=diff
==============================================================================
--- cocoon/blocks/unsupported/petstore/trunk/java/org/apache/cocoon/components/flow/javascript/ScriptableConnection.java
(original)
+++ cocoon/blocks/unsupported/petstore/trunk/java/org/apache/cocoon/components/flow/javascript/ScriptableConnection.java
Sat Apr 23 04:38:34 2005
@@ -18,6 +18,7 @@
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
 
 import org.mozilla.javascript.Context;
 import org.mozilla.javascript.Function;
@@ -66,7 +67,7 @@
  * A ScriptableConnection is also a wrapper around a real JDBC Connection and thus 
  * provides all of methods of Connection as well
  *
- * @version CVS $Id: ScriptableConnection.java,v 1.6 2004/03/05 13:02:03 bdelacretaz Exp
$
+ * @version CVS $Id$
  */
 public class ScriptableConnection extends ScriptableObject {
 
@@ -206,9 +207,11 @@
     public Object jsFunction_query(String sql, Object params,
                                    int startRow, int maxRows,
                                    Object funObj) 
-        throws JavaScriptException {
+            throws JavaScriptException {
+
+        PreparedStatement stmt = null;
         try {
-            PreparedStatement stmt = connection.prepareStatement(sql);
+            stmt = connection.prepareStatement(sql);
             Scriptable array = (Scriptable)params;
             if (array != Undefined.instance) {
                 int len = (int)
@@ -272,13 +275,22 @@
             throw e;
         } catch (Exception e) {
             throw new JavaScriptException(e);
+        } finally {
+            try {
+                if (stmt != null) {
+                    stmt.close();
+                }
+            } catch (SQLException sqle) {
+                throw new JavaScriptException(sqle);
+            }
         }
     }
 
     public int jsFunction_update(String sql, Object params) 
         throws JavaScriptException {
+        PreparedStatement stmt = null;
         try {
-            PreparedStatement stmt = connection.prepareStatement(sql);
+            stmt = connection.prepareStatement(sql);
             Scriptable array = (Scriptable)params;
             if (array != Undefined.instance) {
                 int len = (int)
@@ -298,6 +310,14 @@
             return stmt.getUpdateCount();
         } catch (Exception e) {
             throw new JavaScriptException(e);
+        } finally {
+            try {
+                if (stmt != null) {
+                    stmt.close();
+                }
+            } catch (SQLException sqle) {
+                throw new JavaScriptException(sqle);
+            }
         }
     }
 



Mime
View raw message