DatabaseProduct dbType = null; try { dbType = DatabaseProduct.determineDatabaseProduct(getProductName(pm)); } catch (SQLException e) { LOG.warn("Cannot determine database product; assuming OTHER", e);
@SuppressWarnings("nls") private void initialize() { LOG.debug("ObjectStore, initialize called"); // if this method fails, PersistenceManagerProvider will retry for the configured number of times // before giving up pm = PersistenceManagerProvider.getPersistenceManager(); LOG.info("RawStore: {}, with PersistenceManager: {}" + " created in the thread with id: {}", this, pm, Thread.currentThread().getId()); try { String productName = MetaStoreDirectSql.getProductName(pm); sqlGenerator = new SQLGenerator(DatabaseProduct.determineDatabaseProduct(productName), conf); } catch (SQLException e) { LOG.error("error trying to figure out the database product", e); throw new RuntimeException(e); } isInitialized = pm != null; if (isInitialized) { dbType = determineDatabaseProduct(); expressionProxy = createExpressionProxy(conf); if (MetastoreConf.getBoolVar(getConf(), ConfVars.TRY_DIRECT_SQL)) { String schema = PersistenceManagerProvider.getProperty("javax.jdo.mapping.Schema"); schema = org.apache.commons.lang.StringUtils.defaultIfBlank(schema, null); directSql = new MetaStoreDirectSql(pm, conf, schema); } } }
private DB determineDbType() { DB dbType = DB.OTHER; if (runDbCheck("SET @@session.sql_mode=ANSI_QUOTES", "MySql")) { dbType = DB.MYSQL; } else if (runDbCheck("SELECT version FROM v$instance", "Oracle")) { dbType = DB.ORACLE; } else if (runDbCheck("SELECT @@version", "MSSQL")) { dbType = DB.MSSQL; } else { // TODO: maybe we should use getProductName to identify all the DBs String productName = getProductName(); if (productName != null && productName.toLowerCase().contains("derby")) { dbType = DB.DERBY; } } return dbType; }
private DB determineDbType() { DB dbType = DB.OTHER; if (runDbCheck("SET @@session.sql_mode=ANSI_QUOTES", "MySql")) { dbType = DB.MYSQL; } else if (runDbCheck("SELECT version FROM v$instance", "Oracle")) { dbType = DB.ORACLE; } else if (runDbCheck("SELECT @@version", "MSSQL")) { dbType = DB.MSSQL; } else { // TODO: maybe we should use getProductName to identify all the DBs String productName = getProductName(); if (productName != null && productName.toLowerCase().contains("derby")) { dbType = DB.DERBY; } } return dbType; }
/** * private helper to do initialization routine, so we can retry if needed if it fails. * @param dsProps */ private void initializeHelper(Properties dsProps) { LOG.info("ObjectStore, initialize called"); prop = dsProps; pm = getPersistenceManager(); try { String productName = MetaStoreDirectSql.getProductName(pm); sqlGenerator = new SQLGenerator(DatabaseProduct.determineDatabaseProduct(productName), conf); } catch (SQLException e) { LOG.error("error trying to figure out the database product", e); throw new RuntimeException(e); } isInitialized = pm != null; if (isInitialized) { dbType = determineDatabaseProduct(); expressionProxy = createExpressionProxy(conf); if (MetastoreConf.getBoolVar(getConf(), ConfVars.TRY_DIRECT_SQL)) { String schema = prop.getProperty("javax.jdo.mapping.Schema"); schema = org.apache.commons.lang.StringUtils.defaultIfBlank(schema, null); directSql = new MetaStoreDirectSql(pm, conf, schema); } } LOG.debug("RawStore: {}, with PersistenceManager: {}" + " created in the thread with id: {}", this, pm, Thread.currentThread().getId()); }