Author: michiel
Date: 2010-01-21 17:41:11 +0100 (Thu, 21 Jan 2010)
New Revision: 40662
Modified:
mmbase/trunk/core/src/main/java/org/mmbase/storage/implementation/database/DatabaseStorageManager.java
Log:
MMB-1915, also using now Connection#isValid (java 6)
Modified:
mmbase/trunk/core/src/main/java/org/mmbase/storage/implementation/database/DatabaseStorageManager.java
===================================================================
---
mmbase/trunk/core/src/main/java/org/mmbase/storage/implementation/database/DatabaseStorageManager.java
2010-01-21 16:33:14 UTC (rev 40661)
+++
mmbase/trunk/core/src/main/java/org/mmbase/storage/implementation/database/DatabaseStorageManager.java
2010-01-21 16:41:11 UTC (rev 40662)
@@ -1095,33 +1095,19 @@
try {
return executeUpdate(query, node, fields);
} catch (SQLException sqe) {
- while (true) {
- Statement s = null;
- ResultSet rs = null;
- try {
- s = activeConnection.createStatement();
- rs = s.executeQuery("SELECT 1 FROM " +
factory.getMMBase().getBuilder("object").getFullTableName() + " WHERE 1 = 0");
// if this goes wrong too it can't be the query
- } catch (SQLException isqe) {
- // so, connection must be broken.
- log.service("Found broken connection, closing it");
- if (activeConnection instanceof
org.mmbase.module.database.MultiConnection) {
- ((org.mmbase.module.database.MultiConnection)
activeConnection).realclose();
- } else {
- activeConnection.close();
- }
- getActiveConnection();
- if (activeConnection.isClosed()) {
- // don't know if that can happen, but if it happens,
this would perhaps avoid an infinite loop (and exception will get thrown in
stead)
- break;
- }
- continue;
- } finally {
- if (s != null) s.close();
- if (rs != null) rs.close();
- }
- break;
+ if (! inTransaction && ! activeConnection.isValid(0)) {
+ // so, connection must be broken.
+ log.service("Found broken connection, closing it");
+ if (activeConnection instanceof
org.mmbase.module.database.MultiConnection) {
+ ((org.mmbase.module.database.MultiConnection)
activeConnection).realclose();
+ } else {
+ activeConnection.close();
+ }
+ getActiveConnection();
+ return executeUpdate(query, node, fields);
+ } else {
+ throw sqe;
}
- return executeUpdate(query, node, fields);
}
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs