diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index 42ae6647d..a6cdc4951 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -22,6 +22,7 @@ import java.sql.ResultSet; import java.sql.SQLClientInfoException; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; import java.sql.SQLPermission; import java.sql.SQLWarning; import java.sql.SQLXML; @@ -7196,7 +7197,9 @@ public PreparedStatement prepareStatement(String sql, String[] columnNames, @Override public void releaseSavepoint(Savepoint savepoint) throws SQLException { loggerExternal.entering(loggingClassName, "releaseSavepoint", savepoint); - SQLServerException.throwNotSupportedException(this, null); + MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_featureNotSupported")); + Object[] msgArgs = {"releaseSavepoint"}; + throw new SQLFeatureNotSupportedException(form.format(msgArgs)); } final private Savepoint setNamedSavepoint(String sName) throws SQLServerException { diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/unit/SavepointTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/unit/SavepointTest.java index 63a9c9567..9dad4703f 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/unit/SavepointTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/unit/SavepointTest.java @@ -4,12 +4,14 @@ */ package com.microsoft.sqlserver.jdbc.unit; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import java.sql.Connection; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; import java.text.MessageFormat; import com.microsoft.sqlserver.jdbc.TestUtils; @@ -136,4 +138,23 @@ public void testSavePointWithAutoCommit() throws SQLException { } catch (SQLException e) {} } } + + /** + * Test releaseSavepoint. + * + * @throws SQLException + */ + @Test + public void testReleaseSavepoint() throws SQLException { + try (Connection connection = getConnection()) { + try { + connection.releaseSavepoint(null); + } catch (SQLException e) { + assertEquals(e.getClass(), SQLFeatureNotSupportedException.class, "Expected exception type " + SQLFeatureNotSupportedException.class.getName() + ", but received " + e.getClass().getName()); + + assertTrue(e.getMessage().matches(TestUtils.formatErrorMsg("R_featureNotSupported"))); + } + } + } + }