Skip to content

Commit 17707a5

Browse files
committed
Remove redundant exception handling
1 parent a2feb7b commit 17707a5

File tree

1 file changed

+12
-24
lines changed

1 file changed

+12
-24
lines changed

src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/StatementTest.java

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3094,10 +3094,10 @@ public void testExecuteDelAndSelect() {
30943094
/**
30953095
* Tests multi-statement PreparedStatement with loop to process all results
30963096
*
3097-
* @throws Exception
3097+
* @throws SQLException
30983098
*/
30993099
@Test
3100-
public void testMultiStatementPreparedStatementLoopResults() {
3100+
public void testMultiStatementPreparedStatementLoopResults() throws SQLException {
31013101
try (Connection con = getConnection()) {
31023102
try (PreparedStatement ps = con.prepareStatement("DELETE FROM " + tableName + " " +
31033103
"INSERT INTO " + tableName + " (NAME) VALUES (?) " +
@@ -3137,18 +3137,16 @@ public void testMultiStatementPreparedStatementLoopResults() {
31373137
retval = ps.getMoreResults();
31383138
} while (true);
31393139
}
3140-
} catch (SQLException e) {
3141-
fail(TestResource.getResource("R_unexpectedException") + e.getMessage());
31423140
}
31433141
}
31443142

31453143
/**
31463144
* Tests PreparedStatement execute for Insert followed by select
31473145
*
3148-
* @throws Exception
3146+
* @throws SQLException
31493147
*/
31503148
@Test
3151-
public void testPreparedStatementExecuteInsertAndSelect() {
3149+
public void testPreparedStatementExecuteInsertAndSelect() throws SQLException {
31523150
try (Connection con = getConnection()) {
31533151
String sql = "INSERT INTO " + tableName + " (NAME) VALUES(?) " +
31543152
"SELECT NAME FROM " + tableName + " WHERE ID = 1";
@@ -3176,18 +3174,16 @@ public void testPreparedStatementExecuteInsertAndSelect() {
31763174
retval = ps.getMoreResults();
31773175
} while (true);
31783176
}
3179-
} catch (SQLException e) {
3180-
fail(TestResource.getResource("R_unexpectedException") + e.getMessage());
31813177
}
31823178
}
31833179

31843180
/**
31853181
* Tests PreparedStatement execute for Merge followed by select
31863182
*
3187-
* @throws Exception
3183+
* @throws SQLException
31883184
*/
31893185
@Test
3190-
public void testPreparedStatementExecuteMergeAndSelect() {
3186+
public void testPreparedStatementExecuteMergeAndSelect() throws SQLException {
31913187
try (Connection con = getConnection()) {
31923188
String sql = "MERGE INTO " + tableName + " AS target " +
31933189
"USING (VALUES (?)) AS source (name) " +
@@ -3219,18 +3215,16 @@ public void testPreparedStatementExecuteMergeAndSelect() {
32193215
retval = ps.getMoreResults();
32203216
} while (true);
32213217
}
3222-
} catch (SQLException e) {
3223-
fail(TestResource.getResource("R_unexpectedException") + e.getMessage());
32243218
}
32253219
}
32263220

32273221
/**
32283222
* Tests PreparedStatement execute two Inserts followed by select
32293223
*
3230-
* @throws Exception
3224+
* @throws SQLException
32313225
*/
32323226
@Test
3233-
public void testPreparedStatementExecuteTwoInsertsRowsAndSelect() {
3227+
public void testPreparedStatementExecuteTwoInsertsRowsAndSelect() throws SQLException {
32343228
try (Connection con = getConnection()) {
32353229
try (PreparedStatement ps = con.prepareStatement("INSERT INTO " + tableName + " (NAME) VALUES(?) INSERT INTO " + tableName + " (NAME) VALUES(?) SELECT NAME from " + tableName + " WHERE ID = 1")) {
32363230
ps.setString(1, "test");
@@ -3257,18 +3251,16 @@ public void testPreparedStatementExecuteTwoInsertsRowsAndSelect() {
32573251
retval = ps.getMoreResults();
32583252
} while (true);
32593253
}
3260-
} catch (SQLException e) {
3261-
fail(TestResource.getResource("R_unexpectedException") + e.getMessage());
32623254
}
32633255
}
32643256

32653257
/**
32663258
* Tests PreparedStatement execute for Update followed by select
32673259
*
3268-
* @throws Exception
3260+
* @throws SQLException
32693261
*/
32703262
@Test
3271-
public void testPreparedStatementExecuteUpdAndSelect() {
3263+
public void testPreparedStatementExecuteUpdAndSelect() throws SQLException {
32723264
try (Connection con = getConnection()) {
32733265
try (PreparedStatement ps = con.prepareStatement("UPDATE " + tableName + " SET NAME = ? SELECT NAME FROM " + tableName + " WHERE ID = 1")) {
32743266
ps.setString(1, "test");
@@ -3294,18 +3286,16 @@ public void testPreparedStatementExecuteUpdAndSelect() {
32943286
retval = ps.getMoreResults();
32953287
} while (true);
32963288
}
3297-
} catch (SQLException e) {
3298-
fail(TestResource.getResource("R_unexpectedException") + e.getMessage());
32993289
}
33003290
}
33013291

33023292
/**
33033293
* Tests PreparedStatement execute for Delete followed by select
33043294
*
3305-
* @throws Exception
3295+
* @throws SQLException
33063296
*/
33073297
@Test
3308-
public void testPreparedStatementExecuteDelAndSelect() {
3298+
public void testPreparedStatementExecuteDelAndSelect() throws SQLException {
33093299
try (Connection con = getConnection()) {
33103300
try (PreparedStatement ps = con.prepareStatement("DELETE FROM " + tableName + " WHERE ID = ? SELECT NAME FROM " + tableName + " WHERE ID = 2")) {
33113301
ps.setInt(1, 1);
@@ -3331,8 +3321,6 @@ public void testPreparedStatementExecuteDelAndSelect() {
33313321
retval = ps.getMoreResults();
33323322
} while (true);
33333323
}
3334-
} catch (SQLException e) {
3335-
fail(TestResource.getResource("R_unexpectedException") + e.getMessage());
33363324
}
33373325
}
33383326

0 commit comments

Comments
 (0)