Search in sources :

Example 1 with DatabaseType

use of org.wso2.carbon.humantask.core.dao.DatabaseType in project carbon-business-process by wso2.

the class AbstractJPAVendorAdapter method determineDbType.

protected DatabaseType determineDbType() {
    Connection con = null;
    DatabaseType dbType = null;
    try {
        con = getDBConnection();
        DatabaseMetaData metaData = con.getMetaData();
        if (metaData != null) {
            String dbProductName = metaData.getDatabaseProductName().toLowerCase();
            int dbMajorVer = metaData.getDatabaseMajorVersion();
            if (log.isDebugEnabled()) {
                log.debug("Using database " + dbProductName + " major version " + dbMajorVer);
            }
            if (dbProductName.contains("db2")) {
                dbType = DatabaseType.DB2;
            } else if (dbProductName.contains("oracle")) {
                dbType = DatabaseType.ORACLE;
            } else if (dbProductName.contains("derby")) {
                dbType = DatabaseType.DERBY;
            } else if (dbProductName.contains("h2")) {
                dbType = DatabaseType.H2;
            } else if (dbProductName.contains("hsql")) {
                dbType = DatabaseType.HSQL;
            } else if (dbProductName.contains("microsoft sql")) {
                dbType = DatabaseType.SQL_SERVER;
            } else if (dbProductName.contains("mysql")) {
                dbType = DatabaseType.MYSQL;
            } else if (dbProductName.contains("postgresql")) {
                dbType = DatabaseType.POSTGRESQL;
            } else if (dbProductName.contains("sybase")) {
                dbType = DatabaseType.SYBASE;
            }
        }
    } catch (SQLException e) {
        log.warn("Unable to determine database dialect.", e);
    } finally {
        close(con);
    }
    return dbType;
}
Also used : DatabaseType(org.wso2.carbon.bpel.b4p.coordination.dao.DatabaseType) SQLException(java.sql.SQLException) Connection(java.sql.Connection) DatabaseMetaData(java.sql.DatabaseMetaData)

Example 2 with DatabaseType

use of org.wso2.carbon.humantask.core.dao.DatabaseType in project carbon-business-process by wso2.

the class AbstractJPAVendorAdapter method determineDbType.

protected DatabaseType determineDbType() {
    Connection con = null;
    DatabaseType dbType = null;
    try {
        con = getDBConnection();
        DatabaseMetaData metaData = con.getMetaData();
        if (metaData != null) {
            String dbProductName = metaData.getDatabaseProductName().toLowerCase();
            int dbMajorVer = metaData.getDatabaseMajorVersion();
            if (log.isDebugEnabled()) {
                log.debug("Using database " + dbProductName + " major version " + dbMajorVer);
            }
            if (dbProductName.contains("db2")) {
                dbType = DatabaseType.DB2;
            } else if (dbProductName.contains("oracle")) {
                dbType = DatabaseType.ORACLE;
            } else if (dbProductName.contains("derby")) {
                dbType = DatabaseType.DERBY;
            } else if (dbProductName.contains("h2")) {
                dbType = DatabaseType.H2;
            } else if (dbProductName.contains("hsql")) {
                dbType = DatabaseType.HSQL;
            } else if (dbProductName.contains("microsoft sql")) {
                dbType = DatabaseType.SQL_SERVER;
            } else if (dbProductName.contains("mysql")) {
                dbType = DatabaseType.MYSQL;
            } else if (dbProductName.contains("postgresql")) {
                dbType = DatabaseType.POSTGRESQL;
            } else if (dbProductName.contains("sybase")) {
                dbType = DatabaseType.SYBASE;
            }
        }
    } catch (SQLException e) {
        log.warn("Unable to determine database dialect.", e);
    } finally {
        close(con);
    }
    return dbType;
}
Also used : DatabaseType(org.wso2.carbon.humantask.core.dao.DatabaseType) SQLException(java.sql.SQLException) Connection(java.sql.Connection) DatabaseMetaData(java.sql.DatabaseMetaData)

Aggregations

Connection (java.sql.Connection)2 DatabaseMetaData (java.sql.DatabaseMetaData)2 SQLException (java.sql.SQLException)2 DatabaseType (org.wso2.carbon.bpel.b4p.coordination.dao.DatabaseType)1 DatabaseType (org.wso2.carbon.humantask.core.dao.DatabaseType)1