问题
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 ?
回答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
来源:https://stackoverflow.com/questions/51740363/query-by-city-name-on-geolite2-mmdb-file-java