Class DatabaseProduct
- java.lang.Object
-
- com.xpn.xwiki.store.DatabaseProduct
-
public final class DatabaseProduct extends Object
Represent a Database Product name as returned byDatabaseMetaData.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.
- Version:
- $Id: 329669043d02a8f5c7d810cc79e8a3e707c7354f $
-
-
Field Summary
Fields Modifier and Type Field 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object object)
String
getProductName()
int
hashCode()
static DatabaseProduct
toProduct(String productNameOrJDBCScheme)
Transform a product name represented as a string into aDatabaseProduct
object.String
toString()
-
-
-
Field Detail
-
ORACLE
public static final DatabaseProduct ORACLE
The Product name and the JDBC scheme to recognize an Oracle DB.
-
DERBY
public static final DatabaseProduct DERBY
The Product name and the JDBC scheme to recognize a Derby DB.
-
HSQLDB
public static final DatabaseProduct HSQLDB
The Product name and the JDBC scheme to recognize a HSQLDB DB.
-
DB2
public static final DatabaseProduct DB2
The Product name and the JDBC scheme to recognize a DB2 DB.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. ThetoProduct(String)
method also hence checks forString.startsWith(String)
rather than an exact match.
-
MYSQL
public static final DatabaseProduct MYSQL
The Product name and the JDBC scheme to recognize a MySQL DB.
-
POSTGRESQL
public static final DatabaseProduct POSTGRESQL
The Product name and the JDBC scheme to recognize a PostgreSQL DB.
-
MSSQL
public static final DatabaseProduct MSSQL
The Product name and the JDBC scheme to recognize a Microsoft SQL Server DB.
-
H2
public static final DatabaseProduct H2
The Product name and the JDBC scheme to recognize a H2 DB.
-
UNKNOWN
public static final DatabaseProduct UNKNOWN
Represents an unknown database for which we were not able to find the product name.
-
-
Method Detail
-
getProductName
public String getProductName()
- Returns:
- the database product name. Example: "Oracle". The returned value should correspond to the value returned
by
DatabaseMetaData.getDatabaseProductName()
.
-
toProduct
public static DatabaseProduct toProduct(String productNameOrJDBCScheme)
Transform a product name represented as a string into aDatabaseProduct
object.- Parameters:
productNameOrJDBCScheme
- the string to parse (can either represent a product name or a URL connection DB scheme- Returns:
- the
DatabaseProduct
object
-
-