Adding Delayed Durability to commit API(#1310)
@@ -3351,6 +3351,20 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
@Override
public void commit() throws SQLServerException {
+ commit(false);
+ }
+
+ /**
+ * Makes all changes made since the previous
+ * commit/rollback permanent and releases any database locks
+ * currently held by this <code>Connection</code> object.
+ * This method should be
+ * used only when auto-commit mode has been disabled.
+ *
+ * @param delayedDurability flag to indicate whether the commit will occur with delayed durability on.
+ * @throws SQLServerException Exception if a database access error occurs,
+ */
+ public void commit(boolean delayedDurability) throws SQLServerException {
loggerExternal.entering(loggingClassName, "commit");
if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
@@ -3358,7 +3372,12 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
checkClosed();
if (!databaseAutoCommitMode)
+ {
+ if (!delayedDurability)
connectionCommand("IF @@TRANCOUNT > 0 COMMIT TRAN", "Connection.commit");
+ else
+ connectionCommand("IF @@TRANCOUNT > 0 COMMIT TRAN WITH ( DELAYED_DURABILITY = ON )", "Connection.commit");
+ }
loggerExternal.exiting(loggingClassName, "commit");
}
