code: public void open(Connection conn, String fileName, long filePosition, final int serverId, boolean nonBlocking)
                                                                                                                    throws IOException {
          try {
              this.conn = conn;
              Class<?> connClazz = Class.forName("com.mysql.jdbc.ConnectionImpl");
              Object unwrapConn = unwrapConnection(conn, connClazz);
              if (unwrapConn == null) {
                  throw new IOException("Unable to unwrap " + conn.getClass().getName()
                                        + " to com.mysql.jdbc.ConnectionImpl");
              }
  
              // Get underlying IO streams for network communications.
              Object connIo = getDeclaredField(unwrapConn, connClazz, "io");
              if (connIo == null) {
                  throw new IOException("Get null field:" + conn.getClass().getName() + "#io");
              }
              mysqlOutput = (OutputStream) getDeclaredField(connIo, connIo.getClass(), "mysqlOutput");
              mysqlInput = (InputStream) getDeclaredField(connIo, connIo.getClass(), "mysqlInput");
  
              if (filePosition == 0) filePosition = BIN_LOG_HEADER_SIZE;
              sendBinlogDump(fileName, filePosition, serverId, nonBlocking);
              position = 0;
          } catch (IOException e) {
              close(); /* Do cleanup */
              logger.error("Error on COM_BINLOG_DUMP: file = " + fileName + ", position = " + filePosition);
              throw e;
          } catch (ClassNotFoundException e) {
              close(); /* Do cleanup */
              throw new IOException("Unable to load com.mysql.jdbc.ConnectionImpl", e);
          }
      }
docs: Connect MySQL master to fetch binlog.