Class DNSRecordSRV

java.lang.Object
com.microsoft.sqlserver.jdbc.dns.DNSRecordSRV
All Implemented Interfaces:
Comparable<DNSRecordSRV>

public class DNSRecordSRV extends Object implements Comparable<DNSRecordSRV>
Represents a DNS SRV Record.
  • Constructor Details

    • DNSRecordSRV

      public DNSRecordSRV(int priority, int weight, int port, String serverName) throws IllegalArgumentException
      Constructs a DNSRecordSRV.
      Parameters:
      priority - is lowest
      weight - 1 at minimum
      port - the port of service
      serverName - the host
      Throws:
      IllegalArgumentException - if priority < 0 or weight <= 1
  • Method Details

    • parseFromDNSRecord

      public static DNSRecordSRV parseFromDNSRecord(String record) throws IllegalArgumentException
      Parses a DNS SRC Record from a DNS String record.
      Parameters:
      record - the record to parse
      Returns:
      a not null DNS Record
      Throws:
      IllegalArgumentException - if record is not correct and cannot be parsed
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(DNSRecordSRV o)
      Specified by:
      compareTo in interface Comparable<DNSRecordSRV>
    • getPriority

      public int getPriority()
      Returns the priority of DNS SRV record.
      Returns:
      a positive priority, where lowest values have to be considered first.
    • getWeight

      public int getWeight()
      Returns the weight of DNS record from 0 to 65535.
      Returns:
      The weight, higher value means higher probability of selecting the given record for a given priority.
    • getPort

      public int getPort()
      Returns the IP port of record.
      Returns:
      a value from 1 to 65535.
    • getServerName

      public String getServerName()
      Returns the DNS server name.
      Returns:
      a not null server name.