List of usage examples for java.sql DatabaseMetaData getDriverName
String getDriverName() throws SQLException;
From source file:org.talend.cwm.db.connection.ConnectionUtils.java
/** * DOC zshen Comment method "isOdbcMssql". feature 10630 * /*from w ww. ja va 2s . co m*/ * @param connection * @return * @throws SQLException */ public static boolean isOdbcExcel(java.sql.Connection connection) throws SQLException { @SuppressWarnings("deprecation") DatabaseMetaData connectionMetadata = org.talend.utils.sql.ConnectionUtils .getConnectionMetadata(connection); if (connectionMetadata.getDriverName() != null && connectionMetadata.getDriverName().toLowerCase().startsWith(DatabaseConstant.ODBC_DRIVER_NAME) && connectionMetadata.getDatabaseProductName() != null && connectionMetadata.getDatabaseProductName().equals(DatabaseConstant.ODBC_EXCEL_PRODUCT_NAME)) { return true; } return false; }
From source file:org.talend.cwm.db.connection.ConnectionUtils.java
/** * DOC zshen Comment method "isOdbcConnection". feature 10630 * /* ww w.j a v a2s . c om*/ * @param connection * @return * @throws SQLException */ public static boolean isOdbcConnection(java.sql.Connection connection) throws SQLException { @SuppressWarnings("deprecation") DatabaseMetaData connectionMetadata = org.talend.utils.sql.ConnectionUtils .getConnectionMetadata(connection); if (connectionMetadata.getDriverName() != null && connectionMetadata.getDriverName().toLowerCase().startsWith(DatabaseConstant.ODBC_DRIVER_NAME)) { return true; } return false; }
From source file:org.talend.cwm.db.connection.ConnectionUtils.java
/** * DOC xqliu Comment method "isOdbcPostgresql". * /* ww w.j a v a2 s. co m*/ * @param connection * @return * @throws SQLException */ public static boolean isOdbcPostgresql(java.sql.Connection connection) throws SQLException { @SuppressWarnings("deprecation") DatabaseMetaData connectionMetadata = org.talend.utils.sql.ConnectionUtils .getConnectionMetadata(connection); if (connectionMetadata.getDriverName() != null && connectionMetadata.getDriverName().toLowerCase().startsWith(DatabaseConstant.ODBC_DRIVER_NAME) && connectionMetadata.getDatabaseProductName() != null && connectionMetadata.getDatabaseProductName().toLowerCase() .indexOf(DatabaseConstant.POSTGRESQL_PRODUCT_NAME) > -1) { return true; } return false; }
From source file:org.talend.cwm.db.connection.ConnectionUtils.java
/** * DOC xqliu Comment method "isOdbcOracle". * /* w ww . j a va 2s.c o m*/ * @param connection * @return * @throws SQLException */ public static boolean isOdbcOracle(java.sql.Connection connection) throws SQLException { @SuppressWarnings("deprecation") DatabaseMetaData connectionMetadata = org.talend.utils.sql.ConnectionUtils .getConnectionMetadata(connection); if (connectionMetadata.getDriverName() != null && connectionMetadata.getDriverName().toLowerCase().startsWith(DatabaseConstant.ODBC_DRIVER_NAME) && connectionMetadata.getDatabaseProductName() != null && connectionMetadata.getDatabaseProductName().toLowerCase() .indexOf(DatabaseConstant.ODBC_ORACLE_PRODUCT_NAME) > -1) { return true; } return false; }
From source file:org.talend.cwm.db.connection.ConnectionUtils.java
/** * // ww w . j av a2 s .c o m * DOC qiongli Comment method "isOdbcOracle". * * @param connection * @return * @throws SQLException */ public static boolean isOdbcTeradata(java.sql.Connection connection) throws SQLException { @SuppressWarnings("deprecation") DatabaseMetaData connectionMetadata = org.talend.utils.sql.ConnectionUtils .getConnectionMetadata(connection); if (connectionMetadata.getDriverName() != null && connectionMetadata.getDriverName().toLowerCase().startsWith(DatabaseConstant.ODBC_DRIVER_NAME) && connectionMetadata.getDatabaseProductName() != null && connectionMetadata.getDatabaseProductName().toLowerCase() .indexOf(DatabaseConstant.ODBC_TERADATA_PRODUCT_NAME) > -1) { return true; } return false; }
From source file:org.talend.cwm.db.connection.ConnectionUtils.java
/** * DOC xqliu Comment method "isOdbcIngres". * //from w ww . ja va2 s.c om * @param connection * @return * @throws SQLException */ public static boolean isOdbcIngres(java.sql.Connection connection) throws SQLException { @SuppressWarnings("deprecation") DatabaseMetaData connectionMetadata = org.talend.utils.sql.ConnectionUtils .getConnectionMetadata(connection); if (connectionMetadata.getDriverName() != null && connectionMetadata.getDriverName().toLowerCase().startsWith(DatabaseConstant.ODBC_DRIVER_NAME) && connectionMetadata.getDatabaseProductName() != null && connectionMetadata.getDatabaseProductName().toLowerCase() .indexOf(DatabaseConstant.INGRES_PRODUCT_NAME) > -1) { return true; } return false; }
From source file:org.talend.cwm.db.connection.ConnectionUtils.java
/** * DOC xqliu Comment method "isJdbcIngres". * /*from w ww. j av a 2 s .co m*/ * @param connection * @return * @throws SQLException */ @SuppressWarnings("deprecation") public static boolean isJdbcIngres(java.sql.Connection connection) throws SQLException { DatabaseMetaData connectionMetadata = org.talend.utils.sql.ConnectionUtils .getConnectionMetadata(connection); if (connectionMetadata.getDriverName() != null && connectionMetadata.getDriverName().equals(DatabaseConstant.JDBC_INGRES_DEIVER_NAME) && connectionMetadata.getDatabaseProductName() != null && connectionMetadata.getDatabaseProductName().toLowerCase() .indexOf(DatabaseConstant.INGRES_PRODUCT_NAME) > -1) { return true; } return false; }
From source file:org.talend.dq.analysis.ColumnAnalysisSqlExecutor.java
/** * DOC xqliu Comment method "canParallel". * //from w w w. j a v a2s . c om * @return */ private boolean canParallel(Connection connection) { try { @SuppressWarnings("deprecation") DatabaseMetaData connectionMetadata = org.talend.utils.sql.ConnectionUtils .getConnectionMetadata(connection); if (connectionMetadata.getDriverName() != null && connectionMetadata.getDriverName().toLowerCase() .startsWith(DatabaseConstant.ODBC_DRIVER_NAME)) { return false; } // ADD msjian 2011-6-24 22483 fixed: fixed "java.sql.SQLException: database is locked" // because the sqlite db is not supported the parallel very well if ("SQLite".equals(connection.getMetaData().getDatabaseProductName())) { //$NON-NLS-1$ return false; } if (ExtractMetaDataUtils.getInstance().isHiveConnection(connection)) { // TDQ-12020 only Hive2 supports connection concurrency. org.talend.core.model.metadata.builder.connection.Connection analysisDataProvider = getAnalysisDataProvider( cachedAnalysis); DatabaseConnection dbConn = ((DatabaseConnection) analysisDataProvider); String hiveVersion = dbConn.getParameters().get(ConnParameterKeys.HIVE_SERVER_VERSION); if (HiveServerVersionInfo.HIVE_SERVER_1.getKey().equals(hiveVersion)) { return false; } // TDQ-13909: when run Hive on Spark not support Parallel // TODO: if we have a new hive on spark envirement and test profiling run well, we can remove this part String jdbcProperties = dbConn.getParameters() .get(ConnParameterKeys.CONN_PARA_KEY_HIVE_JDBC_PROPERTIES); List<Map<String, Object>> hiveJDBCPropertiesList = HadoopRepositoryUtil .getHadoopPropertiesList(jdbcProperties); if (!hiveJDBCPropertiesList.isEmpty()) { List keyList = new ArrayList(); List valueList = new ArrayList(); for (Map<String, Object> propertyMap : hiveJDBCPropertiesList) { keyList.add(propertyMap.get("PROPERTY")); //$NON-NLS-1$ valueList.add(propertyMap.get("VALUE")); //$NON-NLS-1$ } if (keyList.contains("hive.execution.engine") && valueList.contains("spark")) { //$NON-NLS-1$ //$NON-NLS-2$ return false; } } // TDQ-13909~ return true; } } catch (SQLException e) { log.warn(e, e); } return this.parallel; }
From source file:org.talend.metadata.managment.model.DBConnectionFillerImpl.java
@Override public List<Schema> fillSchemaToCatalog(DatabaseConnection dbConn, DatabaseMetaData dbJDBCMetadata, Catalog catalog, List<String> schemaFilter) throws Throwable { ResultSet schemaRs = null;//from w ww . j ava2 s. c om try { // Case of JDK 1.6 if (dbJDBCMetadata.getDriverName().equals(DatabaseConstant.MSSQL_DRIVER_NAME_JDBC2_0)) { Method getSchemaMethod = dbJDBCMetadata.getClass().getMethod("getSchemas", String.class, //$NON-NLS-1$ String.class); schemaRs = (ResultSet) getSchemaMethod.invoke(dbJDBCMetadata, catalog.getName(), null); } } catch (SecurityException e) { // Case of JDK1.5 } catch (NoSuchMethodException e) { // do nothing here !!! } catch (IllegalArgumentException e) { // do nothing here !!! } catch (IllegalAccessException e) { // do nothing here !!! } catch (InvocationTargetException e) { // Case of JDK1.5 if (e.getTargetException().getClass().toString().equals("SQLServerException")) { //$NON-NLS-1$ throw e.getTargetException(); } } catch (SQLException e) { log.error(e, e); } if (schemaRs == null) { try { if (dbJDBCMetadata instanceof SybaseDatabaseMetaData) { schemaRs = ((SybaseDatabaseMetaData) dbJDBCMetadata).getSchemas(catalog.getName(), null); } else if (dbJDBCMetadata instanceof AS400DatabaseMetaData) { String schemaPattern = null; if (!schemaFilter.isEmpty()) { schemaPattern = schemaFilter.get(0); } schemaRs = dbJDBCMetadata.getSchemas(catalog.getName(), schemaPattern); } else { schemaRs = dbJDBCMetadata.getSchemas(); } } catch (SQLException e) { if (log.isDebugEnabled()) { log.debug(e, e); } } } List<String> schemaNameCacheTmp = new ArrayList<String>(); List<Schema> schemaList = new ArrayList<Schema>(); if (schemaRs == null) { log.error("Schema result set is null"); //$NON-NLS-1$ } else { try { while (schemaRs.next()) { String schemaName = getSchemaName(schemaRs, dbJDBCMetadata, catalog); if (schemaName == null) { continue; } // MOD mzhao bug 9606 filter duplicated schemas. if (!schemaNameCacheTmp.contains(schemaName) && !MetadataConnectionUtils.isMysql(dbJDBCMetadata)) { if (dbConn != null && !isNullUiSchema(dbConn)) { // this case we only create one schema which name is same as UiSchema Schema createByUiSchema = createSchemaByUiSchema(dbConn); schemaList.add(createByUiSchema); break; } else if (isCreateElement(schemaFilter, schemaName)) { Schema schema = SchemaHelper.createSchema(schemaName); schemaList.add(schema); schemaNameCacheTmp.add(schemaName); } } } } catch (Exception e) { if (log.isDebugEnabled()) { log.debug(e, e); } } finally { schemaRs.close(); } } return schemaList; }
From source file:org.talend.metadata.managment.utils.MetadataConnectionUtils.java
public static boolean isOdbcPostgresql(DatabaseMetaData connectionMetadata) throws SQLException { if (connectionMetadata.getDriverName() != null && connectionMetadata.getDriverName().toLowerCase().startsWith(DatabaseConstant.ODBC_DRIVER_NAME) && connectionMetadata.getDatabaseProductName() != null && connectionMetadata.getDatabaseProductName().toLowerCase() .indexOf(DatabaseConstant.POSTGRESQL_PRODUCT_NAME) > -1) { return true; }//from w ww . j a v a 2 s. c o m return false; }