3

I am using GeoLite2 to get Location by IP address for my java appliccation.

I want to get country by city from GeoLite2-City.mmdb file.

This is my reader :

DatabaseReader reader = new DatabaseReader.Builder(dbFileStream).withCache(new CHMCache()).build();

I am getting CityResponse by IP address like below :

 CityResponse cityResponse = reader.city(InetAddress.getByName("an IP address"));

But I want to get Country name by city like this :

String countryName = reader.getCountryByCity("Paris”);

Is there any way to do this ?

sam
  • 1,073
  • 4
  • 13
  • 27

1 Answers1

1

This isn't possible. The database is designed to do lookups by IP address. I would suggest using the CSV files that MaxMind provides if you need to access the data in some other way.

Also, you can try project geonames.org and their java-api library

Dmitriy
  • 234
  • 2
  • 7