code: public void switchReadOnlyConnection(Boolean mustBeReadOnly) throws SQLException {
      if (urlParser.getOptions().assureReadOnly && currentReadOnlyAsked != mustBeReadOnly) {
        proxy.lock.lock();
        try {
          // verify not updated now that hold lock, double check safe due to volatile
          if (currentReadOnlyAsked != mustBeReadOnly) {
            currentReadOnlyAsked = mustBeReadOnly;
            setSessionReadOnly(mustBeReadOnly, currentProtocol);
          }
        } finally {
          proxy.lock.unlock();
        }
      }
    }
docs: Force session to read-only according to options.
  
  @param mustBeReadOnly is read-only flag
  @throws SQLException if a connection error occur