How do I use MaxMind's GeoIP database to determine location?

An SO User picture An SO User · Feb 7, 2013 · Viewed 12.2k times · Source

So, I was told in my previous question that I can use the databases provided by MaxMind to determine locations.

So, I got their databases downloaded from their site. They are csv files and open up in Excel.

InetAddress ip = InetAddress.getLocalHost() is how I get the IP of my computer. From there I do String justIP = ip.getHostAddress()

My question is:

  • How do I resolve justIP to a city location using the DB I just downloaded ???

  • I am new to this so a little help will be appreciated.

    One of the files has three columns. startIPNum, endIPNum and locID I do not know what these do but I guess locID maps to a city and country location in the other file.

    Answer

    Fusselchen picture Fusselchen · Feb 7, 2013

    Did you tried the Java examples from Maxmind? http://dev.maxmind.com/geoip/downloadable#Java-8
    And see http://dev.maxmind.com/geoip/csv for field descriptions