com.microsoft.sqlserver.jdbc.dns.DNSUtilities Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mssql-jdbc Show documentation
Show all versions of mssql-jdbc Show documentation
Microsoft JDBC Driver for SQL Server.
/*
* Microsoft JDBC Driver for SQL Server Copyright(c) Microsoft Corporation All rights reserved. This program is made
* available under the terms of the MIT License. See the LICENSE file in the project root for more information.
*/
package com.microsoft.sqlserver.jdbc.dns;
import java.util.Hashtable;
import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
/**
* Provides utility functions for the DNS package
*/
public class DNSUtilities {
private final static Logger LOG = Logger.getLogger(DNSUtilities.class.getName());
private static final Level DNS_ERR_LOG_LEVEL = Level.FINE;
/**
* default constructor
*/
public DNSUtilities() {}
/**
* Finds all SRV Record using DNS.
*
* @param dnsSrvRecordToFind
* the DNS record, for instance: _ldap._tcp.dc._msdcs.DOMAIN.COM to find all LDAP servers in DOMAIN.COM
* @return the collection of records with facilities to find the best candidate
* @throws NamingException
* if DNS is not available
*/
public static Set findSrvRecords(final String dnsSrvRecordToFind) throws NamingException {
Hashtable