com.xpn.xwiki.store
Class DatabaseProduct

java.lang.Object
  extended by com.xpn.xwiki.store.DatabaseProduct

public final class DatabaseProduct
extends Object

Represent a Database Product name as returned by 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.

Version:
$Id: ee95684be0d1f53bf1a881f637c77f789c4b7f9c $

Field Summary
static DatabaseProduct DB2
          The product name for DB2 databases.
static DatabaseProduct DERBY
          The product name for Derby databases.
static DatabaseProduct HSQLDB
          The product name for HSQLDB databases.
static DatabaseProduct MSSQL
          The product name for Microsoft SQL Server databases.
static DatabaseProduct MYSQL
          The product name for MySQL databases.
static DatabaseProduct ORACLE
          The product name for Oracle databases.
static DatabaseProduct POSTGRESQL
          The product name for PostgreSQL databases.
static DatabaseProduct UNKNOWN
          Represents an unknown database for which we were not able to find the product name.
 
Method Summary
 boolean equals(Object object)
           
 String getProductName()
           
 int hashCode()
           
static DatabaseProduct toProduct(String productNameAsString)
          Transform a product name represented as a string into a DatabaseProduct object.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ORACLE

public static final DatabaseProduct ORACLE
The product name for Oracle databases.


DERBY

public static final DatabaseProduct DERBY
The product name for Derby databases.


HSQLDB

public static final DatabaseProduct HSQLDB
The product name for HSQLDB databases.


DB2

public static final DatabaseProduct DB2
The product name for DB2 databases.

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.


MYSQL

public static final DatabaseProduct MYSQL
The product name for MySQL databases.


POSTGRESQL

public static final DatabaseProduct POSTGRESQL
The product name for PostgreSQL databases.


MSSQL

public static final DatabaseProduct MSSQL
The product name for Microsoft SQL Server databases.


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().

equals

public boolean equals(Object object)
Overrides:
equals in class Object

toProduct

public static DatabaseProduct toProduct(String productNameAsString)
Transform a product name represented as a string into a DatabaseProduct object.

Parameters:
productNameAsString - the string to transform
Returns:
the DatabaseProduct object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2004-2013 XWiki. All Rights Reserved.