diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index 3973bfc83..78e2eb90e 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -3333,6 +3333,20 @@ final byte[] getTransactionDescriptor() { @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 Connection 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()); @@ -3340,7 +3354,12 @@ public void commit() throws SQLServerException { checkClosed(); if (!databaseAutoCommitMode) - connectionCommand("IF @@TRANCOUNT > 0 COMMIT TRAN", "Connection.commit"); + { + 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"); }