code: public void readEofPacket() throws SQLException, IOException {
      Buffer buffer = reader.getPacket(true);
      switch (buffer.getByteAt(0)) {
        case EOF:
          buffer.skipByte();
          this.hasWarnings = buffer.readShort() > 0;
          this.serverStatus = buffer.readShort();
          break;
  
        case ERROR:
          ErrorPacket ep = new ErrorPacket(buffer);
          throw new SQLException("Could not connect: " + ep.getMessage(), ep.getSqlState(),
              ep.getErrorNumber());
  
        default:
          throw new SQLException("Unexpected packet type " + buffer.getByteAt(0)
              + " instead of EOF");
      }
    }
docs: Check that next read packet is a End-of-file packet.
  
  @throws SQLException if not a End-of-file packet
  @throws IOException  if connection error occur