code: public void reconnect() throws SQLException {
      SearchFilter filter;
      boolean inTransaction = false;
      if (currentReadOnlyAsked) {
        filter = new SearchFilter(true, true);
      } else {
        inTransaction = masterProtocol != null && masterProtocol.inTransaction();
        filter = new SearchFilter(true, urlParser.getOptions().failOnReadOnly);
      }
      reconnectFailedConnection(filter);
      handleFailLoop();
      if (inTransaction) {
        throw new ReconnectDuringTransactionException(
            "Connection reconnect automatically during an active transaction", 1401, "25S03");
      }
    }
docs: Reconnect failed connection.
  
  @throws SQLException if reconnection has failed