@@ -122,19 +122,23 @@ private Map<String, Object> checkMySQLHealth() {
122122 details .put ("database" , extractDatabaseName (dbUrl ));
123123
124124 return performHealthCheck ("MySQL" , details , () -> {
125- try (Connection connection = dataSource .getConnection ()) {
126- if (connection .isValid (2 )) {
127- try (PreparedStatement stmt = connection .prepareStatement (DB_HEALTH_CHECK_QUERY )) {
128- stmt .setQueryTimeout (3 );
129- try (ResultSet rs = stmt .executeQuery ()) {
130- if (rs .next () && rs .getInt (1 ) == 1 ) {
131- String version = getMySQLVersion (connection );
132- return new HealthCheckResult (true , version , null );
125+ try {
126+ try (Connection connection = dataSource .getConnection ()) {
127+ if (connection .isValid (2 )) {
128+ try (PreparedStatement stmt = connection .prepareStatement (DB_HEALTH_CHECK_QUERY )) {
129+ stmt .setQueryTimeout (3 );
130+ try (ResultSet rs = stmt .executeQuery ()) {
131+ if (rs .next () && rs .getInt (1 ) == 1 ) {
132+ String version = getMySQLVersion (connection );
133+ return new HealthCheckResult (true , version , null );
134+ }
133135 }
134136 }
135137 }
138+ return new HealthCheckResult (false , null , "Connection validation failed" );
136139 }
137- return new HealthCheckResult (false , null , "Connection validation failed" );
140+ } catch (Exception e ) {
141+ throw new RuntimeException (e );
138142 }
139143 });
140144 }
0 commit comments