org.glassfish.persistence.common.database
Class DBVendorTypeHelper

java.lang.Object
  extended by org.glassfish.persistence.common.database.DBVendorTypeHelper

public class DBVendorTypeHelper
extends Object

Author:
Mitesh Meswani This class defines string constants representing database names. This class is responsible to translate given database name to internal name.

Field Summary
static String DB2
           
static int DB2_ENUM
           
static String DEFAULT_DB
           
static int DEFAULT_DB_ENUM
           
static String DERBY
           
static int DERBY_ENUM
           
static String INFORMIX
           
static int INFORMIX_ENUM
           
static String INGRES
           
static int INGRES_ENUM
           
static int MAX_KNOWN_DB
           
static String MSSQL
           
static int MSSQL_ENUM
           
static String MYSQL
           
static int MYSQL_ENUM
           
static String ORACLE
           
static int ORACLE_ENUM
           
static int OTHER_ENUM
           
static String POINTBASE
           
static int POINTBASE_ENUM
           
static String SYBASE
           
static int SYBASE_ENUM
           
static String SYMFOWARE
           
static int SYMFOWARE_ENUM
           
 
Constructor Summary
DBVendorTypeHelper()
           
 
Method Summary
static String getDBType(String vendorName)
          Get Database Vendor Type from vendor name.
static int getEnumDBType(DatabaseMetaData metaData)
          Gets enumerated database type for given metaData
static int getEnumDBType(String dbType)
          Gets enumerated database type for given dbType
static boolean requireUpperCaseSchema(DatabaseMetaData dmd)
          Determines whether to use uppercase schema name for a give database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OTHER_ENUM

public static final int OTHER_ENUM
See Also:
Constant Field Values

DEFAULT_DB_ENUM

public static final int DEFAULT_DB_ENUM
See Also:
Constant Field Values

ORACLE_ENUM

public static final int ORACLE_ENUM
See Also:
Constant Field Values

POINTBASE_ENUM

public static final int POINTBASE_ENUM
See Also:
Constant Field Values

MSSQL_ENUM

public static final int MSSQL_ENUM
See Also:
Constant Field Values

SYBASE_ENUM

public static final int SYBASE_ENUM
See Also:
Constant Field Values

DB2_ENUM

public static final int DB2_ENUM
See Also:
Constant Field Values

MYSQL_ENUM

public static final int MYSQL_ENUM
See Also:
Constant Field Values

INFORMIX_ENUM

public static final int INFORMIX_ENUM
See Also:
Constant Field Values

INGRES_ENUM

public static final int INGRES_ENUM
See Also:
Constant Field Values

DERBY_ENUM

public static final int DERBY_ENUM
See Also:
Constant Field Values

SYMFOWARE_ENUM

public static final int SYMFOWARE_ENUM
See Also:
Constant Field Values

MAX_KNOWN_DB

public static final int MAX_KNOWN_DB
See Also:
Constant Field Values

DEFAULT_DB

public static final String DEFAULT_DB

ORACLE

public static final String ORACLE

POINTBASE

public static final String POINTBASE

MSSQL

public static final String MSSQL

SYBASE

public static final String SYBASE

DB2

public static final String DB2

MYSQL

public static final String MYSQL

INFORMIX

public static final String INFORMIX

INGRES

public static final String INGRES

DERBY

public static final String DERBY

SYMFOWARE

public static final String SYMFOWARE
Constructor Detail

DBVendorTypeHelper

public DBVendorTypeHelper()
Method Detail

getDBType

public static String getDBType(String vendorName)
Get Database Vendor Type from vendor name.

Parameters:
vendorName - Input vendor name. Typically this is obtained by querying DatabaseMetaData.
Returns:
Database type that corresponds to vendorName. If vendorName does not match any of predefined vendor names, the database type returned is generated using following logic.
        detectedDbType = vendorName.toUpperCase(Locale.ENGLISH);
        int i = detectedDbType.indexOf('/');
        if (i > -1) {
           detectedDbType = detectedDbType.substring(0, i);
        }
 
If vendorName is null, DEFAULT_DB is returned.

getEnumDBType

public static int getEnumDBType(DatabaseMetaData metaData)
                         throws SQLException
Gets enumerated database type for given metaData

Parameters:
metaData - Input DataBaseMetaData.
Returns:
Enumerated database type as described by getEnumDBType(java.lang.String).
Throws:
SQLException

getEnumDBType

public static int getEnumDBType(String dbType)
Gets enumerated database type for given dbType

Parameters:
dbType - Input database Type. This should have been obtained from a previous call to getDBType(java.lang.String)
Returns:
dbType translated to one of the enumerations above. If dbType does not correspond to one of the predefined types, OTHER is returned

requireUpperCaseSchema

public static boolean requireUpperCaseSchema(DatabaseMetaData dmd)
                                      throws SQLException
Determines whether to use uppercase schema name for a give database.

Parameters:
dmd - The DatabaseMetaData for the database
Returns:
true if upper case schemaname is to be used. False otherwise.
Throws:
SQLException


Copyright © 2012. All Rights Reserved.