use of org.talend.core.model.metadata.builder.database.ExtractMetaDataUtils in project tdi-studio-se by Talend.
the class QueryGuessCommand method generateNewQuery.
private String generateNewQuery() {
// used for generating new Query.
ExtractMetaDataUtils extractMeta = ExtractMetaDataUtils.getInstance();
if (realDBType != null) {
dbType = realDBType;
}
//
if (node != null && node instanceof INode) {
process = ((INode) node).getProcess();
}
if (this.realTableId != null && this.dbNameAndDbTypeMap.containsKey(this.realTableId)) {
dbType = this.dbNameAndDbTypeMap.get(this.realTableId);
}
if (dbType == null || dbType.equals("")) {
//$NON-NLS-1$
IElementParameter ptParam = node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
if (ptParam != null && ptParam.getRepositoryValue() != null) {
if (ptParam.getRepositoryValue().endsWith(EDatabaseTypeName.GENERAL_JDBC.getProduct())) {
dbType = EDatabaseTypeName.GENERAL_JDBC.getDisplayName();
}
}
}
boolean isJdbc = false;
INode connectionNode = null;
IElementParameter existConnection = node.getElementParameter("USE_EXISTING_CONNECTION");
boolean useExistConnection = (existConnection == null ? false : (Boolean) existConnection.getValue());
if (useExistConnection) {
IElementParameter connector = node.getElementParameter("CONNECTION");
if (connector != null) {
String connectorValue = connector.getValue().toString();
List<? extends INode> graphicalNodes = process.getGeneratingNodes();
for (INode node : graphicalNodes) {
if (node.getUniqueName().equals(connectorValue)) {
connectionNode = node;
break;
}
}
}
}
// hywang add for bug 7575
if (dbType != null && dbType.equals(EDatabaseTypeName.GENERAL_JDBC.getDisplayName())) {
isJdbc = true;
String driverClassName = node.getElementParameter("DRIVER_CLASS").getValue().toString();
if (connectionNode != null) {
driverClassName = connectionNode.getElementParameter("DRIVER_CLASS").getValue().toString();
}
driverClassName = TalendTextUtils.removeQuotes(driverClassName);
//
if (driverClassName != null && !"".equals(driverClassName)) {
boolean isContextModeDriverClass = ContextParameterUtils.containContextVariables(driverClassName);
if (isContextModeDriverClass) {
driverClassName = JavaProcessUtil.getContextOriginalValue(process, driverClassName);
}
}
// specil handle Sybase Database's driverClassName
if (driverClassName != null && !"".equals(driverClassName)) {
if (driverClassName.equals("com.sybase.jdbc3.jdbc.SybDataSource")) {
driverClassName = EDatabase4DriverClassName.SYBASEASE.getDriverClass();
}
}
// DRIVER_JAR:
String driverJarName = node.getElementParameter("DRIVER_JAR").getValue().toString();
if (connectionNode != null) {
driverJarName = connectionNode.getElementParameter("DRIVER_JAR").getValue().toString();
}
if (driverJarName != null && driverJarName.startsWith("[") && driverJarName.endsWith("]")) {
driverJarName = driverJarName.substring(1, driverJarName.length() - 1);
if (driverJarName != null && driverJarName.startsWith("{") && driverJarName.endsWith("}")) {
driverJarName = driverJarName.substring(1, driverJarName.length() - 1);
}
}
if (driverJarName != null && !"".equals(driverJarName)) {
boolean isContextMode = ContextParameterUtils.containContextVariables(driverJarName);
if (isContextMode) {
driverJarName = JavaProcessUtil.getContextOriginalValue(process, driverJarName);
}
dbType = extractMeta.getDbTypeByClassNameAndDriverJar(driverClassName, driverJarName);
} else {
dbType = extractMeta.getDbTypeByClassName(driverClassName);
}
DatabaseConnection dbConn = null;
if (dbType == null) {
// handle context mode
if (conn != null) {
if (conn instanceof DatabaseConnection) {
dbConn = (DatabaseConnection) conn;
}
driverClassName = DatabaseConnectionParameterUtil.getTrueParamValue(dbConn, driverClassName);
dbType = extractMeta.getDbTypeByClassName(driverClassName);
}
}
if (dbType == null) {
// if we can not get the DB Type from the existing driver list, just set back the type to ORACLE
// since it's one DB unknown from Talend.
// it might not work directly for all DB, but it will generate a standard query.
dbType = EDatabaseTypeName.ORACLE_OCI.getDisplayName();
}
// data view, conn=null
// need add code here for dbtype(oracle)
}
if (dbNameAndSchemaMap != null) {
schema = this.dbNameAndSchemaMap.get(this.realTableId);
}
String propertyType = (String) node.getPropertyValue(EParameterName.PROPERTY_TYPE.getName());
boolean isTeradata = false;
if (dbType != null) {
isTeradata = dbType.equalsIgnoreCase(EDatabaseTypeName.TERADATA.getDisplayName());
}
if (propertyType != null && !propertyType.equals(EmfComponent.REPOSITORY)) {
List<? extends IElementParameter> elementParameters = this.node.getElementParameters();
if (useExistConnection) {
elementParameters = connectionNode.getElementParameters();
}
for (IElementParameter param : elementParameters) {
if (param.getRepositoryValue() != null) {
if (//$NON-NLS-1$
(!isTeradata && param.getRepositoryValue().equals("SCHEMA")) || (isTeradata && param.getRepositoryValue().equals("SID"))) {
// check if dbtype is //$NON-NLS-1$
// Teradata, always keep the
// query style like
// "dbname.tablename.columnname" on build-in mode
schema = (String) param.getValue();
//$NON-NLS-1$ //$NON-NLS-2$
schema = schema.replace("\"", "");
//$NON-NLS-1$ //$NON-NLS-2$
schema = schema.replace("\'", "");
break;
}
}
}
} else if (schema == null) {
IElementParameter param = node.getElementParameter(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
if (param != null) {
try {
IRepositoryViewObject object = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getLastVersion((String) param.getValue());
if (object != null) {
Item item = object.getProperty().getItem();
if (item != null && item instanceof DatabaseConnectionItem) {
if (isTeradata) {
schema = (String) RepositoryToComponentProperty.getValue(((DatabaseConnectionItem) item).getConnection(), "SID", //$NON-NLS-1$
null);
} else {
schema = (String) RepositoryToComponentProperty.getValue(((DatabaseConnectionItem) item).getConnection(), "SCHEMA", //$NON-NLS-1$
null);
}
schema = TalendTextUtils.removeQuotes(schema);
}
}
} catch (PersistenceException e) {
//
}
}
}
// if (conn instanceof DatabaseConnection && conn.isContextMode()) {
// schema = DatabaseConnectionParameterUtil.getContextTrueValue((DatabaseConnection) conn, schema);
// }
String newQuery = null;
realTableName = QueryUtil.getTableName(node, newOutputMetadataTable, schema, dbType, realTableName);
if (realTableName.startsWith(TalendTextUtils.QUOTATION_MARK) && realTableName.endsWith(TalendTextUtils.QUOTATION_MARK) && realTableName.length() > 2) {
realTableName = realTableName.substring(1, realTableName.length() - 1);
}
if (conn != null && (isJdbc || dbType.equals(EDatabaseTypeName.JAVADB_EMBEDED.getDisplayName()) || (StringUtils.isEmpty(schema) && (EDatabaseTypeName.ORACLE_CUSTOM.equals(EDatabaseTypeName.getTypeFromDbType(dbType)) || EDatabaseTypeName.ORACLEFORSID.equals(EDatabaseTypeName.getTypeFromDbType(dbType)) || EDatabaseTypeName.ORACLESN.equals(EDatabaseTypeName.getTypeFromDbType(dbType)) || EDatabaseTypeName.ORACLE_OCI.equals(EDatabaseTypeName.getTypeFromDbType(dbType)))))) {
schema = getDefaultSchema(realTableName);
}
newQuery = QueryUtil.generateNewQuery(node, newOutputMetadataTable, isJdbc, dbType, schema, realTableName);
// Added yyin TDQ-5616: if there are where clause, append it to the query
if (whereClause != null) {
// the where clause is inputted by the user, so no need to modify it.
//$NON-NLS-1$
newQuery = newQuery.substring(0, newQuery.length() - 1) + whereClause + "\"";
}
return TalendTextUtils.addSQLQuotes(newQuery);
}
use of org.talend.core.model.metadata.builder.database.ExtractMetaDataUtils in project tdi-studio-se by Talend.
the class AbstractElementPropertySectionController method setAllConnectionParameters.
private void setAllConnectionParameters(String typ, IElement element) {
IElementParameter basePropertyParameter = null;
for (IElementParameter param : elem.getElementParameters()) {
if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
if (param.getRepositoryValue().startsWith("DATABASE")) {
basePropertyParameter = param;
break;
}
}
}
// jobsetting view load the db info from current selected category
IElementParameter updateBasePropertyParameter = updateBasePropertyParameter();
if (updateBasePropertyParameter != null && !updateBasePropertyParameter.equals(basePropertyParameter)) {
basePropertyParameter = updateBasePropertyParameter;
}
String type = null;
ExtractMetaDataUtils extractMeta = ExtractMetaDataUtils.getInstance();
if (typ != null && !typ.equals("")) {
//$NON-NLS-1$
type = typ;
} else {
//$NON-NLS-1$
type = getValueFromRepositoryName(element, "TYPE", basePropertyParameter);
}
if (type.equals("Oracle") || type.contains("OCLE")) {
IElementParameter ele = element.getElementParameter("CONNECTION_TYPE");
if (ele != null) {
type = (String) ele.getValue();
} else {
//$NON-NLS-1$
type = "ORACLE_SID";
}
}
// Get real hsqldb type
if (type.equals(EDatabaseTypeName.HSQLDB.name()) && getValueFromRepositoryName(element, "RUNNING_MODE", basePropertyParameter).equals("HSQLDB_INPROGRESS_PERSISTENT")) {
//$NON-NLS-1$
type = EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName();
}
// If the dbtype has been setted don't reset it again unless the dbtype of connParameters is null.
if (StringUtils.trimToNull(type) == null && StringUtils.trimToNull(connParameters.getDbType()) == null) {
type = EDatabaseTypeName.GENERAL_JDBC.getXmlName();
}
if (StringUtils.trimToNull(type) != null) {
connParameters.setDbType(type);
}
//$NON-NLS-1$
String frameWorkKey = getValueFromRepositoryName(element, "FRAMEWORK_TYPE", basePropertyParameter);
connParameters.setFrameworkType(frameWorkKey);
String schema = getValueFromRepositoryName(element, EConnectionParameterName.SCHEMA.getName(), basePropertyParameter);
connParameters.setSchema(schema);
String userName = getValueFromRepositoryName(element, EConnectionParameterName.USERNAME.getName(), basePropertyParameter);
connParameters.setUserName(userName);
String password = getValueFromRepositoryName(element, EConnectionParameterName.PASSWORD.getName(), basePropertyParameter);
connParameters.setPassword(password);
String host = getValueFromRepositoryName(element, EConnectionParameterName.SERVER_NAME.getName(), basePropertyParameter);
connParameters.setHost(host);
String port = getValueFromRepositoryName(element, EConnectionParameterName.PORT.getName(), basePropertyParameter);
connParameters.setPort(port);
boolean https = Boolean.parseBoolean(getValueFromRepositoryName(element, EConnectionParameterName.HTTPS.getName(), basePropertyParameter));
connParameters.setHttps(https);
boolean isOracleOCI = type.equals(EDatabaseTypeName.ORACLE_OCI.getXmlName()) || type.equals(EDatabaseTypeName.ORACLE_OCI.getDisplayName());
if (isOracleOCI) {
String localServiceName = getValueFromRepositoryNameAndParameterName(element, EConnectionParameterName.SID.getName(), EParameterName.LOCAL_SERVICE_NAME.getName());
// sid is the repository value both for DBName and Local_service_name
connParameters.setLocalServiceName(localServiceName);
}
String datasource = getValueFromRepositoryName(element, EConnectionParameterName.DATASOURCE.getName(), basePropertyParameter);
connParameters.setDatasource(datasource);
// qli modified to fix the bug "7364".
String dbName = getValueFromRepositoryName(element, EConnectionParameterName.SID.getName(), basePropertyParameter);
if (EDatabaseTypeName.EXASOL.getDisplayName().equals(connParameters.getDbType())) {
if (dbName.contains("\\\"")) {
dbName = dbName.replace("\\\"", "");
}
dbName = TextUtil.removeQuots(dbName);
} else if (EDatabaseTypeName.GENERAL_JDBC.getDisplayName().equals(connParameters.getDbType())) {
//$NON-NLS-1$
dbName = "";
}
connParameters.setDbName(dbName);
if (connParameters.getDbType().equals(EDatabaseTypeName.SQLITE.getXmlName()) || connParameters.getDbType().equals(EDatabaseTypeName.ACCESS.getXmlName()) || connParameters.getDbType().equals(EDatabaseTypeName.FIREBIRD.getXmlName())) {
String file = getValueFromRepositoryName(element, EConnectionParameterName.FILE.getName(), basePropertyParameter);
connParameters.setFilename(file);
}
String dir = getValueFromRepositoryName(element, EConnectionParameterName.DIRECTORY.getName(), basePropertyParameter);
if (type.equals(EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName())) {
dir = getValueFromRepositoryName(elem, EConnectionParameterName.DBPATH.getName(), basePropertyParameter);
}
connParameters.setDirectory(dir);
// General jdbc
String url = getValueFromRepositoryName(element, EConnectionParameterName.URL.getName(), basePropertyParameter);
if (StringUtils.isEmpty(url)) {
// to get the Oracle RAC url.
if (EDatabaseTypeName.ORACLE_CUSTOM.getXmlName().equals(type)) {
url = getValueFromRepositoryName(element, "RAC_" + EConnectionParameterName.URL.getName(), basePropertyParameter);
}
}
connParameters.setUrl(TalendTextUtils.removeQuotes(url));
String driverJar = getValueFromRepositoryName(element, EConnectionParameterName.DRIVER_JAR.getName(), basePropertyParameter);
connParameters.setDriverJar(TalendTextUtils.removeQuotes(driverJar));
String driverClass = getValueFromRepositoryName(element, EConnectionParameterName.DRIVER_CLASS.getName(), basePropertyParameter);
String dbVersion = getValueFromRepositoryName(element, "DB_VERSION", basePropertyParameter);
connParameters.setDbVersion(dbVersion);
if (EDatabaseVersion4Drivers.VERTICA_5_1.getVersionValue().equals(dbVersion) || EDatabaseVersion4Drivers.VERTICA_6.getVersionValue().equals(dbVersion) || EDatabaseVersion4Drivers.VERTICA_6_1_X.getVersionValue().equals(dbVersion) || EDatabaseVersion4Drivers.VERTICA_7.getVersionValue().equals(dbVersion)) {
driverClass = EDatabase4DriverClassName.VERTICA2.getDriverClass();
}
connParameters.setDriverClass(TalendTextUtils.removeQuotes(driverClass));
if (driverClass != null && !"".equals(driverClass) && !EDatabaseTypeName.GENERAL_JDBC.getDisplayName().equals(connParameters.getDbType())) {
if (driverClass.startsWith("\"") && driverClass.endsWith("\"")) {
driverClass = TalendTextUtils.removeQuotes(driverClass);
}
String dbTypeByClassName = "";
if (driverJar != null && !"".equals(driverJar)) {
dbTypeByClassName = extractMeta.getDbTypeByClassNameAndDriverJar(driverClass, driverJar);
} else {
dbTypeByClassName = extractMeta.getDbTypeByClassName(driverClass);
}
if (dbTypeByClassName != null) {
connParameters.setDbType(dbTypeByClassName);
}
}
String jdbcProps = getValueFromRepositoryName(element, EConnectionParameterName.PROPERTIES_STRING.getName(), basePropertyParameter);
connParameters.setJdbcProperties(jdbcProps);
String realTableName = null;
if (EmfComponent.REPOSITORY.equals(elem.getPropertyValue(EParameterName.SCHEMA_TYPE.getName()))) {
final Object propertyValue = elem.getPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
IMetadataTable metadataTable = null;
String connectionId = propertyValue.toString().split(" - ")[0];
String tableLabel = propertyValue.toString().split(" - ")[1];
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(connectionId);
if (repobj != null) {
Property property = repobj.getProperty();
if (property != null) {
item = property.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
Connection connection = ((ConnectionItem) item).getConnection();
for (org.talend.core.model.metadata.builder.connection.MetadataTable table : ConnectionHelper.getTables(connection)) {
if (table.getLabel().equals(tableLabel)) {
metadataTable = ConvertionHelper.convert(table);
break;
}
}
}
if (metadataTable != null) {
realTableName = metadataTable.getTableName();
}
}
connParameters.setSchemaName(QueryUtil.getTableName(elem, connParameters.getMetadataTable(), TalendTextUtils.removeQuotes(schema), type, realTableName));
}
use of org.talend.core.model.metadata.builder.database.ExtractMetaDataUtils in project tdi-studio-se by Talend.
the class TracesConnectionUtils method createConnection.
/**
* DOC hwang Comment method "createConnection".
*/
public static DatabaseConnection createConnection(ConnectionParameters parameters) {
ExtractMetaDataUtils extractMeta = ExtractMetaDataUtils.getInstance();
String dbType = parameters.getDbType();
boolean isNeedSchema = EDatabaseTypeName.getTypeFromDbType(dbType).isNeedSchema();
String productName = EDatabaseTypeName.getTypeFromDisplayName(dbType).getProduct();
// boolean isOralceWithSid = productName.equals(EDatabaseTypeName.ORACLEFORSID.getProduct());
String schema = parameters.getSchema();
EDatabaseTypeName type = EDatabaseTypeName.getTypeFromDbType(dbType);
if (ManagerConnection.isSchemaFromSidOrDatabase(type)) {
schema = parameters.getDbName();
}
if ("".equals(schema) && EDatabaseTypeName.INFORMIX.getProduct().equals(productName)) {
//$NON-NLS-1$
schema = parameters.getUserName();
}
if (EDatabaseTypeName.EXASOL.getProduct().equals(productName)) {
schema = parameters.getDbName();
}
boolean isSchemaInValid = //$NON-NLS-1$ //$NON-NLS-2$
(schema == null) || (schema.equals("\'\'")) || (schema.equals("\"\"")) || //$NON-NLS-1$
(schema.trim().equals(""));
// from 616 till line 622 modified by hyWang
NotReallyNeedSchemaDBS dbs = new NotReallyNeedSchemaDBS();
dbs.init();
List<String> names = dbs.getNeedSchemaDBNames();
boolean ifNeedSchemaDB = names.contains(productName);
if (isNeedSchema && isSchemaInValid && !ifNeedSchemaDB) {
//$NON-NLS-1$
parameters.setConnectionComment(Messages.getString("TracesConnectionUtils.connectionComment"));
return null;
}
DatabaseConnection connection = ConnectionFactory.eINSTANCE.createDatabaseConnection();
connection.setFileFieldName(parameters.getFilename());
connection.setDatabaseType(dbType);
connection.setUsername(parameters.getUserName());
connection.setPort(parameters.getPort());
connection.setRawPassword(parameters.getPassword());
if (dbType != null && dbType.equals(EDatabaseTypeName.ORACLE_OCI.getDisplayName()) && parameters.getLocalServiceName() != null && !"".equals(parameters.getLocalServiceName())) {
connection.setSID(parameters.getLocalServiceName());
} else {
connection.setSID(parameters.getDbName());
}
connection.setLabel(parameters.getDbName());
connection.setDatasourceName(parameters.getDatasource());
if (parameters.getDbType().equals(EDatabaseTypeName.GODBC.getDisplayName()) && StringUtils.isEmpty(parameters.getDatasource())) {
connection.setDatasourceName(parameters.getDbName());
}
if ("".equals(connection.getLabel())) {
//$NON-NLS-1$
connection.setLabel(parameters.getDatasource());
}
String driverClassByDbType = null;
if (parameters.getDriverClass() != null) {
driverClassByDbType = parameters.getDriverClass();
} else {
driverClassByDbType = extractMeta.getDriverClassByDbType(dbType);
}
String driverJar = parameters.getDriverJar();
connection.setDriverClass(driverClassByDbType);
connection.setDriverJarPath(driverJar);
String databaseType = connection.getDatabaseType();
if (driverClassByDbType != null && !"".equals(driverClassByDbType) && EDatabaseTypeName.GENERAL_JDBC.getDisplayName().equals(parameters.getDbType())) {
if (driverClassByDbType.startsWith("\"") && driverClassByDbType.endsWith("\"")) {
driverClassByDbType = TalendTextUtils.removeQuotes(driverClassByDbType);
}
String dbTypeByClassName = "";
if (driverJar != null && !"".equals(driverJar)) {
dbTypeByClassName = extractMeta.getDbTypeByClassNameAndDriverJar(driverClassByDbType, driverJar);
} else {
dbTypeByClassName = extractMeta.getDbTypeByClassName(driverClassByDbType);
}
if (dbTypeByClassName != null) {
databaseType = dbTypeByClassName;
}
}
final String product = EDatabaseTypeName.getTypeFromDisplayName(databaseType).getProduct();
;
connection.setProductId(product);
if (MetadataTalendType.getDefaultDbmsFromProduct(product) != null) {
final String mapping = MetadataTalendType.getDefaultDbmsFromProduct(product).getId();
connection.setDbmsId(mapping);
}
if (!isSchemaInValid && isNeedSchema) {
//$NON-NLS-1$ //$NON-NLS-2$
schema = schema.replaceAll("\'", "");
//$NON-NLS-1$ //$NON-NLS-2$
schema = schema.replaceAll("\"", "");
connection.setUiSchema(schema);
}
connection.setServerName(parameters.getHost());
connection.setAdditionalParams(parameters.getJdbcProperties());
connection.setURL(parameters.getCombineURL());
connection.setDBRootPath(parameters.getDirectory());
connection.setDbVersionString(parameters.getDbVersion());
// Added by Marvin Wang to add other parameters.
Map<String, String> params = parameters.getParameters();
if (params != null && params.size() > 0) {
Set<Entry<String, String>> collection = params.entrySet();
for (Entry<String, String> para : collection) {
connection.getParameters().put(para.getKey(), para.getValue());
}
}
return connection;
}
use of org.talend.core.model.metadata.builder.database.ExtractMetaDataUtils in project tdi-studio-se by Talend.
the class MetadataColumnComparator method updatePackage.
private void updatePackage(IMetadataConnection metadataConnectionTemp) {
if (metadataConnectionTemp == null) {
return;
}
Driver derbyDriver = null;
java.sql.Connection sqlConn = null;
ExtractMetaDataUtils extractMeta = ExtractMetaDataUtils.getInstance();
// get dbType before get connection so that the dbtype won't be null.TDI-18366
String dbType = metadataConnectionTemp.getDbType();
DatabaseConnection dbConn = (DatabaseConnection) metadataConnectionTemp.getCurrentConnection();
List list = MetadataConnectionUtils.getConnection(metadataConnectionTemp);
for (int i = 0; i < list.size(); i++) {
if (list.get(i) instanceof Driver) {
String driverClass = metadataConnectionTemp.getDriverClass();
if (MetadataConnectionUtils.isDerbyRelatedDb(driverClass, dbType)) {
derbyDriver = (Driver) list.get(i);
}
}
if (list.get(i) instanceof java.sql.Connection) {
sqlConn = (java.sql.Connection) list.get(i);
}
}
try {
if (sqlConn != null) {
DatabaseMetaData dm = null;
// Added by Marvin Wang on Mar. 13, 2013 for loading hive jars dynamically, refer to TDI-25072.
if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType)) {
dm = HiveConnectionManager.getInstance().extractDatabaseMetaData(metadataConnectionTemp);
} else {
dm = extractMeta.getDatabaseMetaData(sqlConn, dbType, false, metadataConnectionTemp.getDatabase());
}
MetadataFillFactory.getDBInstance().fillCatalogs(dbConn, dm, MetadataConnectionUtils.getPackageFilter(dbConn, dm, true));
MetadataFillFactory.getDBInstance().fillSchemas(dbConn, dm, MetadataConnectionUtils.getPackageFilter(dbConn, dm, false));
}
} catch (Exception e) {
ExceptionHandler.process(e);
} finally {
if (sqlConn != null) {
ConnectionUtils.closeConnection(sqlConn);
}
if (derbyDriver != null) {
try {
//$NON-NLS-1$
derbyDriver.connect("jdbc:derby:;shutdown=true", null);
} catch (SQLException e) {
// exception of shutdown success. no need to catch.
}
}
}
}
use of org.talend.core.model.metadata.builder.database.ExtractMetaDataUtils in project tdi-studio-se by Talend.
the class SessionTreeNodeUtils method createSQLConnection.
private static List createSQLConnection(DatabaseConnection con, String selectedContext, IMetadataConnection iMetadataConnection) throws Exception {
// bug 17980
ExtractMetaDataUtils extractMeta = ExtractMetaDataUtils.getInstance();
List list = extractMeta.getConnection(iMetadataConnection.getDbType(), iMetadataConnection.getUrl(), iMetadataConnection.getUsername(), iMetadataConnection.getPassword(), iMetadataConnection.getDatabase(), iMetadataConnection.getSchema(), iMetadataConnection.getDriverClass(), iMetadataConnection.getDriverJarPath(), iMetadataConnection.getDbVersionString(), iMetadataConnection.getAdditionalParams());
SQLConnection sqlConnection = new SQLConnection(extractMeta.getConn(), null);
if (sqlConnection != null) {
list.add(sqlConnection);
}
return list;
}
Aggregations