code: public static Protocol retrieveProxy(final UrlParser urlParser, final GlobalStateInfo globalInfo)
        throws SQLException {
      final ReentrantLock lock = new ReentrantLock();
      Protocol protocol;
      switch (urlParser.getHaMode()) {
        case AURORA:
          return getProxyLoggingIfNeeded(urlParser, (Protocol) Proxy.newProxyInstance(
              AuroraProtocol.class.getClassLoader(),
              new Class[]{Protocol.class},
              new FailoverProxy(new AuroraListener(urlParser, globalInfo), lock)));
        case REPLICATION:
          return getProxyLoggingIfNeeded(urlParser,
              (Protocol) Proxy.newProxyInstance(
                  MastersSlavesProtocol.class.getClassLoader(),
                  new Class[]{Protocol.class},
                  new FailoverProxy(new MastersSlavesListener(urlParser, globalInfo), lock)));
        case FAILOVER:
        case SEQUENTIAL:
          return getProxyLoggingIfNeeded(urlParser, (Protocol) Proxy.newProxyInstance(
              MasterProtocol.class.getClassLoader(),
              new Class[]{Protocol.class},
              new FailoverProxy(new MastersFailoverListener(urlParser, globalInfo), lock)));
        default:
          protocol = getProxyLoggingIfNeeded(urlParser,
              new MasterProtocol(urlParser, globalInfo, lock));
          protocol.connectWithoutProxy();
          return protocol;
      }
    }
docs: Retrieve protocol corresponding to the failover options. if no failover option, protocol will
  not be proxied. if a failover option is precised, protocol will be proxied so that any
  connection error will be handle directly.
  
  @param urlParser  urlParser corresponding to connection url string.
  @param globalInfo global variable information
  @return protocol
  @throws SQLException if any error occur during connection