use of org.talend.dq.analysis.parameters.DBConnectionParameter in project tdq-studio-se by Talend.
the class MultiColAnalysisCreationTest method getDataManager.
/**
* DOC scorreia Comment method "getDataManager".
*
* @return
*/
public Connection getDataManager() {
// $NON-NLS-1$
TypedProperties connectionParams = PropertiesLoader.getProperties(AllDataProfilerCoreTests.class, "db.properties");
// $NON-NLS-1$
String driverClassName = connectionParams.getProperty("driver");
// $NON-NLS-1$
String dbUrl = connectionParams.getProperty("url");
// $NON-NLS-1$
String sqlTypeName = connectionParams.getProperty("sqlTypeName");
DBConnectionParameter params = new DBConnectionParameter();
// $NON-NLS-1$
params.setName("My connection");
params.setDriverClassName(driverClassName);
params.setJdbcUrl(dbUrl);
params.setSqlTypeName(sqlTypeName);
params.setParameters(connectionParams);
params.getParameters();
// create connection
ConnectionUtils.setTimeout(false);
MetadataFillFactory instance = MetadataFillFactory.getDBInstance();
IMetadataConnection metaConnection = instance.fillUIParams(ParameterUtil.toMap(params));
ReturnCode rc = null;
try {
rc = instance.checkConnection(metaConnection);
} catch (java.lang.RuntimeException e) {
Assert.fail("connect to " + dbUrl + "failed," + e.getMessage());
}
Connection dataProvider = null;
if (rc.isOk()) {
dataProvider = instance.fillUIConnParams(metaConnection, null);
dataProvider.setName(DATA_PROVIDER_NAME);
// because the DI side code is changed, modify the following code.
metaConnection.setCurrentConnection(dataProvider);
try {
ProjectNodeHelper.fillCatalogAndSchemas(metaConnection, (DatabaseConnection) dataProvider);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Assert.assertNotNull(dataProvider);
return dataProvider;
}
use of org.talend.dq.analysis.parameters.DBConnectionParameter in project tdq-studio-se by Talend.
the class ConnectionUtils method createConnectionParam.
/**
* DOC xqliu Comment method "createConnectionParam".
*
* @param conn
* @return
*/
public static DBConnectionParameter createConnectionParam(Connection conn) {
DBConnectionParameter connectionParam = new DBConnectionParameter();
Properties properties = new Properties();
// MOD xqliu 2010-08-06 bug 14593
properties.setProperty(TaggedValueHelper.USER, JavaSqlFactory.getUsername(conn));
properties.setProperty(TaggedValueHelper.PASSWORD, JavaSqlFactory.getPassword(conn));
// ~ 14593
connectionParam.setParameters(properties);
connectionParam.setName(conn.getName());
connectionParam.setAuthor(MetadataHelper.getAuthor(conn));
connectionParam.setDescription(MetadataHelper.getDescription(conn));
connectionParam.setPurpose(MetadataHelper.getPurpose(conn));
connectionParam.setStatus(MetadataHelper.getDevStatus(conn));
connectionParam.setDriverPath(((DatabaseConnection) conn).getDriverJarPath());
connectionParam.setDriverClassName(JavaSqlFactory.getDriverClass(conn));
connectionParam.setJdbcUrl(JavaSqlFactory.getURL(conn));
connectionParam.setHost(JavaSqlFactory.getServerName(conn));
connectionParam.setPort(JavaSqlFactory.getPort(conn));
if (conn instanceof DatabaseConnection) {
connectionParam.setSqlTypeName(((DatabaseConnection) conn).getDatabaseType());
String dbmsId = ((DatabaseConnection) conn).getDbmsId();
connectionParam.setDbmsId(dbmsId);
// ADD klliu 2011-05-19 21704: Refactoring this "otherParameter" !
connectionParam.setFilterCatalog(dbmsId);
}
// MOD klliu if oracle set schema to other parameter
if (conn instanceof DatabaseConnection) {
DatabaseConnection dbConnection = (DatabaseConnection) conn;
connectionParam.setOtherParameter(dbConnection.getUiSchema());
// ADD klliu 2011-05-19 21704: Refactoring this "otherParameter" !
connectionParam.setFilterSchema(dbConnection.getUiSchema());
}
// MOD mzhao adapte model. MDM connection editing need handle
// additionally.
// connectionParam.getParameters().setProperty(TaggedValueHelper.UNIVERSE,
// DataProviderHelper.getUniverse(connection));
connectionParam.setDbName(JavaSqlFactory.getSID(conn));
// MOD by zshen for bug 15314
String retrieveAllMetadata = MetadataHelper.getRetrieveAllMetadata(conn);
connectionParam.setRetrieveAllMetadata(retrieveAllMetadata == null ? true : new Boolean(retrieveAllMetadata).booleanValue());
return connectionParam;
}
Aggregations