Skip to content

Commit

Permalink
Added test case testRegisterOutParameterWithDecimalException
Browse files Browse the repository at this point in the history
  • Loading branch information
Ananya2 authored Dec 9, 2024
1 parent d4859f1 commit 1506f62
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.junit.runner.RunWith;

import com.microsoft.sqlserver.jdbc.RandomUtil;
import com.microsoft.sqlserver.jdbc.SQLServerCallableStatement;
import com.microsoft.sqlserver.jdbc.SQLServerConnection;
import com.microsoft.sqlserver.jdbc.SQLServerDataSource;
import com.microsoft.sqlserver.jdbc.SQLServerException;
Expand Down Expand Up @@ -1259,6 +1260,25 @@ public void testBigDecimalPrecision() throws SQLException {
}
}

@Test
public void testRegisterOutParameterWithDecimalException() throws SQLException {
try (Connection conn = getConnection()) {
String sql = "{call some_procedure(?)}";
CallableStatement stmt = conn.prepareCall(sql);

stmt.registerOutParameter(1, Types.DECIMAL);
SQLServerCallableStatement sqlServerStmt = (SQLServerCallableStatement) stmt;

try {
sqlServerStmt.registerOutParameter(1, Types.DECIMAL);
fail("Expected SQLServerException to be thrown");
} catch (SQLServerException e) {
assertTrue(e.getCause() instanceof SQLException);
assertEquals("Error fetching scale", e.getCause().getMessage());
}
}
}

@AfterEach
public void terminate() throws Exception {
try (Connection con = getConnection(); Statement stmt = con.createStatement()) {
Expand Down

0 comments on commit 1506f62

Please sign in to comment.