use of org.talend.core.repository.model.connection.ConnectionStatus in project tdi-studio-se by Talend.
the class DbTableController method checkConnection.
/**
* qzhang Comment method "checkConnection".
*
* @param metadataConnection
*/
protected boolean checkConnection(IMetadataConnection metadataConnection) {
try {
ConnectionStatus testConnection = ExtractMetaDataFromDataBase.testConnection(metadataConnection.getDbType(), metadataConnection.getUrl(), metadataConnection.getUsername(), metadataConnection.getPassword(), metadataConnection.getSchema(), metadataConnection.getDriverClass(), metadataConnection.getDriverJarPath(), metadataConnection.getDbVersionString(), metadataConnection.getAdditionalParams());
connParameters.setConnectionComment(testConnection.getMessageException());
if (EDatabaseTypeName.ACCESS.getDisplayName().equals(connParameters.getDbType())) {
return true;
}
return testConnection.getResult();
} catch (Exception e) {
//$NON-NLS-1$ //$NON-NLS-2$
log.error(Messages.getString("CommonWizard.exception") + "\n" + e.toString());
}
return false;
}
use of org.talend.core.repository.model.connection.ConnectionStatus in project tdi-studio-se by Talend.
the class GuessSchemaController method checkConnection.
/**
* qzhang Comment method "checkConnection".
*
* @param metadataConnection
*/
protected boolean checkConnection(IMetadataConnection metadataConnection) {
try {
if (EDatabaseTypeName.HIVE.getDisplayName().equals(metadataConnection.getDbType())) {
ConnectionStatus connectionStatus = new ConnectionStatus();
connectionStatus.setResult(false);
try {
if (HiveModeInfo.get(metadataConnection.getDbVersionString()) == HiveModeInfo.EMBEDDED) {
JavaSqlFactory.doHivePreSetup((DatabaseConnection) metadataConnection.getCurrentConnection());
}
HiveConnectionManager.getInstance().checkConnection(metadataConnection);
connectionStatus.setResult(true);
} catch (Exception e) {
//$NON-NLS-1$//$NON-NLS-2$
log.error("" + "\n" + e.toString());
}
return connectionStatus.getResult();
}
if (EDatabaseTypeName.IMPALA.getDisplayName().equals(metadataConnection.getDbType())) {
ConnectionStatus connectionStatus = new ConnectionStatus();
connectionStatus.setResult(false);
try {
ImpalaConnectionManager.getInstance().checkConnection(metadataConnection);
connectionStatus.setResult(true);
} catch (Exception e) {
//$NON-NLS-1$//$NON-NLS-2$
log.error("" + "\n" + e.toString());
}
return connectionStatus.getResult();
}
ConnectionStatus testConnection = ExtractMetaDataFromDataBase.testConnection(metadataConnection.getDbType(), metadataConnection.getUrl(), metadataConnection.getUsername(), metadataConnection.getPassword(), metadataConnection.getSchema(), metadataConnection.getDriverClass(), metadataConnection.getDriverJarPath(), metadataConnection.getDbVersionString(), metadataConnection.getAdditionalParams());
connParameters.setConnectionComment(testConnection.getMessageException());
return testConnection.getResult();
} catch (Exception e) {
//$NON-NLS-1$//$NON-NLS-2$
log.error("" + "\n" + e.toString());
}
return false;
}
use of org.talend.core.repository.model.connection.ConnectionStatus in project tdi-studio-se by Talend.
the class DbTableController method checkConnection.
/**
* nma Comment method "checkConnection".
*
* @param metadataConnection, IContextManager
*/
protected boolean checkConnection(IMetadataConnection metadataConnection, IContextManager contextManager) {
try {
String DBType = ContextParameterUtils.parseScriptContextCode(metadataConnection.getDbType(), contextManager);
String userName = ContextParameterUtils.parseScriptContextCode(metadataConnection.getUsername(), contextManager);
String password = ContextParameterUtils.parseScriptContextCode(metadataConnection.getPassword(), contextManager);
String schema = ContextParameterUtils.parseScriptContextCode(metadataConnection.getSchema(), contextManager);
String driveClass = ContextParameterUtils.parseScriptContextCode(metadataConnection.getDriverClass(), contextManager);
String driverJarPath = ContextParameterUtils.parseScriptContextCode(metadataConnection.getDriverJarPath(), contextManager);
String dbVersion = ContextParameterUtils.parseScriptContextCode(metadataConnection.getDbVersionString(), contextManager);
String additionalParams = ContextParameterUtils.parseScriptContextCode(metadataConnection.getAdditionalParams(), contextManager);
// specially used for URL
String server = ContextParameterUtils.parseScriptContextCode(metadataConnection.getServerName(), contextManager);
String port = ContextParameterUtils.parseScriptContextCode(metadataConnection.getPort(), contextManager);
String sidOrDatabase = ContextParameterUtils.parseScriptContextCode(metadataConnection.getDatabase(), contextManager);
String filePath = ContextParameterUtils.parseScriptContextCode(metadataConnection.getFileFieldName(), contextManager);
String datasource = ContextParameterUtils.parseScriptContextCode(metadataConnection.getDataSourceName(), contextManager);
String dbRootPath = ContextParameterUtils.parseScriptContextCode(metadataConnection.getDbRootPath(), contextManager);
String additionParam = ContextParameterUtils.parseScriptContextCode(metadataConnection.getAdditionalParams(), contextManager);
String newURL = DatabaseConnStrUtil.getURLString(DBType, dbVersion, server, userName, password, port, sidOrDatabase, filePath.toLowerCase(), datasource, dbRootPath, additionParam);
ConnectionStatus testConnection = ExtractMetaDataFromDataBase.testConnection(DBType, newURL, userName, password, schema, driveClass, driverJarPath, dbVersion, additionalParams);
ConnectionParameters connParameters2 = new ConnectionParameters();
if (connParameters == null) {
connParameters = connParameters2;
}
connParameters.setConnectionComment(testConnection.getMessageException());
if (EDatabaseTypeName.ACCESS.getDisplayName().equals(connParameters.getDbType())) {
return true;
}
return testConnection.getResult();
} catch (Exception e) {
//$NON-NLS-1$ //$NON-NLS-2$
log.error(Messages.getString("CommonWizard.exception") + "\n" + e.toString());
}
return false;
}
Aggregations