public enum Database extends Enum<Database>
IP2Location provides free LITE databases that are updated on the 1st of each calendar month. Each database type contains different levels of geographic detail, from country-only (DB1) to full location data including timezone information (DB11).
All database types are available in both IPv4-only and IPv6 formats. The IPv6 format contains both IPv4 and IPv6 address mappings but is significantly larger in file size. When IPv6 support is enabled, both databases are downloaded - the IPv4 database for IPv4 lookups and the IPv6 database for IPv6 lookups.
| Database | Fields | IPv4 Size | IPv6 Size |
|---|---|---|---|
| DB1 | Country code, Country name | ~2 MB | ~5 MB |
| DB3 | + Region, City | ~20 MB | ~50 MB |
| DB5 | + Latitude, Longitude | ~25 MB | ~60 MB |
| DB9 | + ZIP code | ~35 MB | ~80 MB |
| DB11 | + Timezone | ~40 MB | ~90 MB |
Check which fields are available in a database type:
Database db = Database.DB5;
db.hasRegion(); // true
db.hasCity(); // true
db.hasCoordinates(); // true
db.hasZipCode(); // false (requires DB9+)
db.hasTimezone(); // false (requires DB11)
Each database type generates download codes for both IPv4 and IPv6 formats:
// IPv4 download code
Database.DB11.getCode(false); // "DB11LITEBIN"
// IPv6 download code
Database.DB11.getCode(true); // "DB11LITEBINIPV6"
// Full download URL
Database.DB11.getDownloadUrl("YOUR_TOKEN", false);
// https://www.ip2location.com/download?token=YOUR_TOKEN&file=DB11LITEBIN
IP2LocationService.Builder.database(Database)| Enum Constant and Description |
|---|
DB1_LITEDB1: Country only. |
DB11_LITEDB11: Full database with all LITE fields. |
DB3_LITEDB3: Country, Region, City. |
DB5_LITEDB5: Country, Region, City, Coordinates. |
DB9_LITEDB9: Country, Region, City, Coordinates, ZIP. |
| Modifier and Type | Method and Description |
|---|---|
static Database | fromCode(String code)Finds a database by its download code. |
static Database | fromType(int type)Finds a database by its type number. |
String | getCode(boolean isIPv6)Returns the download code for the IP2Location download API. |
String | getDescription()Returns a human-readable description of the database contents. |
String | getDownloadUrl(String token, boolean isIPv6)Returns the full download URL for this database. |
int | getType()Returns the database type number. |
boolean | hasCity()Returns whether this database includes city information. |
boolean | hasCoordinates()Returns whether this database includes latitude and longitude. |
boolean | hasRegion()Returns whether this database includes region/state information. |
boolean | hasTimezone()Returns whether this database includes timezone information. |
boolean | hasZipCode()Returns whether this database includes ZIP/postal code. |
boolean | isLite()Gets the flag indicating this is a "LITE" database type that is updated once a month. |
String | toString()Returns a string representation of this database. |
static Database | valueOf(String name)Returns the enum constant of this type with the specified name. |
static Database[] | values()Returns an array containing the constants of this enum type, in the order they are declared. |
public static final Database DB1_LITE
Available fields:
This is the smallest and fastest database, suitable when only country-level information is needed.
public static final Database DB3_LITE
Available fields:
public static final Database DB5_LITE
Available fields:
public static final Database DB9_LITE
Available fields:
public static final Database DB11_LITE
Available fields:
This is the most comprehensive free database available from IP2Location.
public static Database[] values()
for (Database c : Database.values()) System.out.println(c);
public static Database valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic int getType()
The type indicates the level of detail:
public String getCode(boolean isIPv6)
This code is used in the download URL:
https://www.ip2location.com/download?token=TOKEN&file=CODE
Examples:
getCode(false) returns "DB11LITEBIN" for IPv4getCode(true) returns "DB11LITEBINIPV6" for IPv6isIPv6 - true for IPv6 database code, false for IPv4public String getDownloadUrl(String token, boolean isIPv6)
Constructs a complete URL that can be used to download the database file.
token - The download token for IP2Location API authenticationisIPv6 - true for IPv6 database, false for IPv4NullPointerException - if token is nullpublic String getDescription()
public boolean isLite()
The fully-paid versions of the databases are updated more often, there are more of them, and contain a lot more information in the returned results.
public boolean hasRegion()
true if region data is available (type >= 3)public boolean hasCity()
true if city data is available (type >= 3)public boolean hasCoordinates()
true if coordinates are available (type >= 5)public boolean hasZipCode()
true if ZIP code is available (type >= 9)public boolean hasTimezone()
true if timezone is available (type >= 11)public static Database fromType(int type)
type - The database type (1, 3, 5, 9, or 11)IllegalArgumentException - if the type is invalidpublic static Database fromCode(String code)
Accepts both IPv4 and IPv6 codes (e.g., "DB11LITEBIN" or "DB11LITEBINIPV6") and returns the corresponding database type.
code - The download code to search for, case-insensitiveIllegalArgumentException - if no database matches the codeNullPointerException - if code is nullPhantom® and NetPhantom® are registered trademarks of Mindus SARL.
© 2026 Mindus SARL. All rights reserved.