Commit f3639ccc authored by Robin Collier's avatar Robin Collier Committed by rcollier

OF-39 Fixed some commit issues with non transactional connections.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13036 b35dd754-fafc-0310-a699-88a17e54d16e
parent 178efe19
...@@ -997,6 +997,7 @@ public class PubSubPersistenceManager { ...@@ -997,6 +997,7 @@ public class PubSubPersistenceManager {
{ {
log.debug("Flushing items to database"); log.debug("Flushing items to database");
boolean abortTransaction = false;
LinkedList addList = null; LinkedList addList = null;
LinkedList delList = null; LinkedList delList = null;
...@@ -1066,15 +1067,15 @@ public class PubSubPersistenceManager { ...@@ -1066,15 +1067,15 @@ public class PubSubPersistenceManager {
delItem = delItem.next; delItem = delItem.next;
} }
} }
con.commit();
} }
catch (SQLException sqle) catch (SQLException sqle)
{ {
log.error(sqle.getMessage(), sqle); log.error(sqle.getMessage(), sqle);
abortTransaction = true;
} }
finally finally
{ {
DbConnectionManager.closeConnection(pstmt, con); DbConnectionManager.closeTransactionConnection(pstmt, con, abortTransaction);
} }
} }
...@@ -1488,17 +1489,17 @@ public class PubSubPersistenceManager { ...@@ -1488,17 +1489,17 @@ public class PubSubPersistenceManager {
String persistentNodeQuery = "SELECT serviceID, nodeID, maxItems FROM ofPubsubNode WHERE " String persistentNodeQuery = "SELECT serviceID, nodeID, maxItems FROM ofPubsubNode WHERE "
+ "leaf=1 AND persistItems=1 AND maxItems > 0"; + "leaf=1 AND persistItems=1 AND maxItems > 0";
boolean abortTransaction = false;
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
PreparedStatement nodeConfig = null;
ResultSet rs = null; ResultSet rs = null;
try try
{ {
con = DbConnectionManager.getTransactionConnection(); con = DbConnectionManager.getTransactionConnection();
nodeConfig = con.prepareStatement(persistentNodeQuery);
PreparedStatement nodeConfig = con.prepareStatement(persistentNodeQuery);
rs = nodeConfig.executeQuery(); rs = nodeConfig.executeQuery();
PreparedStatement purgeNode = con PreparedStatement purgeNode = con
.prepareStatement(getPurgeStatement(DbConnectionManager.getDatabaseType())); .prepareStatement(getPurgeStatement(DbConnectionManager.getDatabaseType()));
...@@ -1510,20 +1511,20 @@ public class PubSubPersistenceManager { ...@@ -1510,20 +1511,20 @@ public class PubSubPersistenceManager {
setPurgeParams(DbConnectionManager.getDatabaseType(), purgeNode, svcId, nodeId, maxItems); setPurgeParams(DbConnectionManager.getDatabaseType(), purgeNode, svcId, nodeId, maxItems);
int rowsAffected = purgeNode.executeUpdate(); purgeNode.addBatch();
if (log.isDebugEnabled())
log.debug(rowsAffected + " deleted rows from service: " + svcId + " nodeId: " + nodeId);
} }
purgeNode.executeBatch();
} }
catch (Exception sqle) catch (Exception sqle)
{ {
sqle.printStackTrace();
log.error(sqle.getMessage(), sqle); log.error(sqle.getMessage(), sqle);
abortTransaction = true;
} }
finally finally
{ {
DbConnectionManager.closeConnection(rs, pstmt, con); DbConnectionManager.closeResultSet(rs);
DbConnectionManager.closeStatement(rs, nodeConfig);
DbConnectionManager.closeTransactionConnection(pstmt, con, abortTransaction);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment