Skip to content

Commit 6cc07a8

Browse files
Move Retry block to Exception handler
1 parent 3fd3e60 commit 6cc07a8

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java

+12-5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* The API javadoc for JDBC API methods that this class implements are not repeated here. Please see Sun's JDBC API
2929
* interfaces javadoc for those details.
3030
*/
31+
@SuppressWarnings("unused")
3132
public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaData, Serializable {
3233
/**
3334
* Always update serialVersionUID when prompted.
@@ -1014,19 +1015,25 @@ public int getMaxColumnsInTable() throws SQLServerException {
10141015
@Override
10151016
public int getMaxConnections() throws SQLException, SQLTimeoutException {
10161017
checkClosed();
1018+
SQLServerResultSet rs = null;
10171019
try {
1018-
SQLServerResultSet rs = getResultSetFromInternalQueries(null,
1020+
rs = getResultSetFromInternalQueries(null,
10191021
"select maximum from sys.configurations where name = 'user connections'");
10201022
if (!rs.next()) {
1021-
// Try with sp_configure if users do not have privileges to execute sys.configurations
1023+
return 0;
1024+
}
1025+
return rs.getInt("maximum");
1026+
} catch (SQLServerException e) {
1027+
// Try with sp_configure if users do not have privileges to execute sys.configurations
1028+
try {
10221029
rs = getResultSetFromInternalQueries(null, "sp_configure 'user connections'");
10231030
if (!rs.next()) {
10241031
return 0;
10251032
}
1033+
return rs.getInt("maximum");
1034+
} catch (SQLServerException e1) {
1035+
return 0;
10261036
}
1027-
return rs.getInt("maximum");
1028-
} catch (SQLServerException e) {
1029-
return 0;
10301037
}
10311038
}
10321039

0 commit comments

Comments
 (0)