Title: [665] trunk/activerecord-jdbc: Fix some interesting strange mixups when doing reconnect (A hint, they weren't working at ALL...)
Revision
665
Author
olabini
Date
2007-07-06 07:56:03 -0400 (Fri, 06 Jul 2007)

Log Message

Fix some interesting strange mixups when doing reconnect (A hint, they weren't working at ALL...)

Modified Paths

Diff

Modified: trunk/activerecord-jdbc/lib/active_record/connection_adapters/jdbc_adapter.rb (664 => 665)


--- trunk/activerecord-jdbc/lib/active_record/connection_adapters/jdbc_adapter.rb	2007-07-05 10:35:08 UTC (rev 664)
+++ trunk/activerecord-jdbc/lib/active_record/connection_adapters/jdbc_adapter.rb	2007-07-06 11:56:03 UTC (rev 665)
@@ -476,6 +476,8 @@
       def reconnect!
         @connection.close rescue nil
         @connection = JdbcConnection.new(@config)
+        @connection.adapter = self
+        @connection
       end
 
       def select_all(sql, name = nil)

Modified: trunk/activerecord-jdbc/src/java/JdbcAdapterInternalService.java (664 => 665)


--- trunk/activerecord-jdbc/src/java/JdbcAdapterInternalService.java	2007-07-05 10:35:08 UTC (rev 664)
+++ trunk/activerecord-jdbc/src/java/JdbcAdapterInternalService.java	2007-07-06 11:56:03 UTC (rev 665)
@@ -158,8 +158,10 @@
                 return runtime.newArray(arr);
             } catch (SQLException e) {
                 if(c.isClosed()) {
-                    recv.callMethod(recv.getRuntime().getCurrentContext(),"reconnect!");
-                    continue;
+                    recv = recv.callMethod(recv.getRuntime().getCurrentContext(),"reconnect!");
+                    if(!((Connection)recv.dataGetStruct()).isClosed()) {
+                        continue;
+                    }
                 }
                 throw e;
             } finally {
@@ -251,8 +253,10 @@
                 return unmarshal_columns(recv, metadata, results);
             } catch(SQLException e) {
                 if(c.isClosed()) {
-                    recv.callMethod(recv.getRuntime().getCurrentContext(),"reconnect!");
-                    continue;
+                    recv = recv.callMethod(recv.getRuntime().getCurrentContext(),"reconnect!");
+                    if(!((Connection)recv.dataGetStruct()).isClosed()) {
+                        continue;
+                    }
                 }
                 throw e;
             }
@@ -376,8 +380,10 @@
                 return recv.getRuntime().newFixnum(stmt.executeUpdate(sql.convertToString().getUnicodeValue()));
             } catch(SQLException e) {
                 if(c.isClosed()) {
-                    recv.callMethod(recv.getRuntime().getCurrentContext(),"reconnect!");
-                    continue;
+                    recv = recv.callMethod(recv.getRuntime().getCurrentContext(),"reconnect!");
+                    if(!((Connection)recv.dataGetStruct()).isClosed()) {
+                        continue;
+                    }
                 }
                 throw e;
             } finally {
@@ -405,8 +411,10 @@
                 return unmarshal_result(recv, stmt.executeQuery(sql.convertToString().getUnicodeValue()));
             } catch(SQLException e) {
                 if(c.isClosed()) {
-                    recv.callMethod(recv.getRuntime().getCurrentContext(),"reconnect!");
-                    continue;
+                    recv = recv.callMethod(recv.getRuntime().getCurrentContext(),"reconnect!");
+                    if(!((Connection)recv.dataGetStruct()).isClosed()) {
+                        continue;
+                    }
                 }
                 throw e;
             } finally {
@@ -429,8 +437,10 @@
                 return unmarshal_id_result(recv.getRuntime(), stmt.getGeneratedKeys());
             } catch(SQLException e) {
                 if(c.isClosed()) {
-                    recv.callMethod(recv.getRuntime().getCurrentContext(),"reconnect!");
-                    continue;
+                    recv = recv.callMethod(recv.getRuntime().getCurrentContext(),"reconnect!");
+                    if(!((Connection)recv.dataGetStruct()).isClosed()) {
+                        continue;
+                    }
                 }
                 throw e;
             } finally {
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to