Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String ip = 85.64.225.159;
- int caching1 = IP2Country.NO_CACHE; // Straight on file, Fastest startup, slowest queries
- int caching2 = IP2Country.MEMORY_MAPPED; // Memory mapped file, fast startup, fast queries.
- int caching3 = IP2Country.MEMORY_CACHE; // load file into memory, slowerst startup, fastest queries
- IP2Country ip2c = new IP2Country(caching1);
- Country c = ip2c.getCountry(ip);
- if (c == null)
- {
- System.out.println("UNKNOWN");
- }
- else
- {
- // will output IL ISR ISRAEL
- System.out.println(c.get2cStr() + " " + c.get3cStr() + " " + c.getName());
- }
- * Begining of IP address range
- * Ending of IP address range
- * Two-character country code based on ISO 3166
- * Three-character country code based on ISO 3166
- * Country name based on ISO 3166
- FIELD DATA TYPE FIELD DESCRIPTION
- IP_FROM NUMERICAL (DOUBLE) Beginning of IP address range.
- IP_TO NUMERICAL (DOUBLE) Ending of IP address range.
- COUNTRY_CODE2 CHAR(2) Two-character country code based on ISO 3166.
- COUNTRY_CODE3 CHAR(3) Three-character country code based on ISO 3166.
- COUNTRY_NAME VARCHAR(50) Country name based on ISO 3166
- SELECT COUNTRY_NAME FROM <TableName> WHERE IP_FROM <= IP Number and IP_TO >= IP Number
- IP Number = A x (256*256*256) + B x (256*256) + C x 256 + D
- SELECT Country from GeoIP where IpFrom < $IP and $IP < $IpTo
- select country from geoip where $ip <= ipTo limit 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement