Monday, February 23, 2015

Whois domain detail by java

Apache commmon org.apache.commons.net.whois.WhoisClient class provides the domain details.

Following details:

Domain Name: UTTESH.COM
Registrar: GODADDY.COM, LLC
Sponsoring Registrar IANA ID: 146
Whois Server: whois.godaddy.com
Referral URL: http://registrar.godaddy.com
Name Server: NS63.DOMAINCONTROL.COM
Name Server: NS64.DOMAINCONTROL.COM
Status: clientDeleteProhibited http://www.icann.org/epp#clientDeleteProhibited
Status: clientRenewProhibited http://www.icann.org/epp#clientRenewProhibited
Status: clientTransferProhibited http://www.icann.org/epp#clientTransferProhibited
Status: clientUpdateProhibited http://www.icann.org/epp#clientUpdateProhibited
Updated Date: 11-jan-2015
Creation Date: 24-jan-2012
Expiration Date: 24-jan-2017

But it will provide only the registry database contains ONLY .COM, .NET, .EDU domains and Registrars.

Sample Code :

/**
 *
 * @author Uttesh Kumar T.H.
 */
import org.apache.commons.net.whois.WhoisClient;

public class WhoIsSample {

    public static void main(String[] args) {

        WhoIsSample obj = new WhoIsSample();
        System.out.println(obj.getWhois("uttesh.com"));
        System.out.println("Done");

    }

    public String getWhois(String domainName) {

        StringBuilder result = new StringBuilder("");

        WhoisClient whois = new WhoisClient();
        try {
            whois.connect(WhoisClient.DEFAULT_HOST);
            String whoisData1 = whois.query("=" + domainName);
            result.append(whoisData1);
            whois.disconnect();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return result.toString();

    }

}

Jar details :

maven dependency

<dependency>
 <groupId>commons-net</groupId>
 <artifactId>commons-net</artifactId>
 <version>2.0</version>
</dependency>

Direct download click here

Reactions: