public final class DatabaseProduct extends Object
DatabaseMetaData.getDatabaseProductName()
.
Ideally we shouldn't have to take care of Database specificities since we're using Hibernate to abstract ourselves from Databases. However it happens that Hibernate doesn't support setting Catalogs on some databases and instead we need to use our own tricks to do that and these tricks depend on the database. Hence the need to differentiate them and hence the need for this class.
Modifier and Type | Field and Description |
---|---|
static DatabaseProduct |
DB2
The Product name and the JDBC scheme to recognize a DB2 DB.
|
static DatabaseProduct |
DERBY
The Product name and the JDBC scheme to recognize a Derby DB.
|
static DatabaseProduct |
H2
The Product name and the JDBC scheme to recognize a H2 DB.
|
static DatabaseProduct |
HSQLDB
The Product name and the JDBC scheme to recognize a HSQLDB DB.
|
static DatabaseProduct |
MSSQL
The Product name and the JDBC scheme to recognize a Microsoft SQL Server DB.
|
static DatabaseProduct |
MYSQL
The Product name and the JDBC scheme to recognize a MySQL DB.
|
static DatabaseProduct |
ORACLE
The Product name and the JDBC scheme to recognize an Oracle DB.
|
static DatabaseProduct |
POSTGRESQL
The Product name and the JDBC scheme to recognize a PostgreSQL DB.
|
static DatabaseProduct |
UNKNOWN
Represents an unknown database for which we were not able to find the product name.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object object) |
String |
getProductName() |
int |
hashCode() |
static DatabaseProduct |
toProduct(String productNameOrJDBCScheme)
Transform a product name represented as a string into a
DatabaseProduct object. |
String |
toString() |
public static final DatabaseProduct ORACLE
public static final DatabaseProduct DERBY
public static final DatabaseProduct HSQLDB
public static final DatabaseProduct DB2
Per DB2 documentation at
http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.apdv.java.doc/doc/c0053013.html, the
database product name returned by the DatabaseMetaData.getDatabaseProductName()
method of DB2
JDBC drivers varies by the OS and environment the product is running on. Hence the DB string here uses only the
first 3 unique characters of the database product name. The toProduct(String)
method also hence checks
for String.startsWith(String)
rather than an exact match.
public static final DatabaseProduct MYSQL
public static final DatabaseProduct POSTGRESQL
public static final DatabaseProduct MSSQL
public static final DatabaseProduct H2
public static final DatabaseProduct UNKNOWN
public String getProductName()
DatabaseMetaData.getDatabaseProductName()
.public static DatabaseProduct toProduct(String productNameOrJDBCScheme)
DatabaseProduct
object.productNameOrJDBCScheme
- the string to parse (can either represent a product name or a URL connection DB
schemeDatabaseProduct
objectCopyright © 2004–2021 XWiki. All rights reserved.