use of net.sourceforge.squirrel_sql.fw.sql.ISQLAlias in project tdi-studio-se by Talend.
the class SessionTreeNodeUtils method createSQLAlias.
/**
* @param url Connection Url
* @param userName DB username
* @param password DB password
* @param databaseName databaseName
* @param name RepositoryName
* @return ISQLAlias
*/
private static ISQLAlias createSQLAlias(String name, String url, String userName, String password, String databaseName) {
SQLAlias alias = new SQLAlias(IdentifierFactory.getInstance().createIdentifier());
try {
alias.setName(databaseName);
alias.setUrl(url);
alias.setUserName(userName);
alias.setPassword(password);
alias.setSchemaFilterExpression(databaseName);
//$NON-NLS-1$
alias.setFolderFilterExpression("Tables,Views,Synonyms");
} catch (Exception e) {
SqlBuilderPlugin.log(e.getMessage(), e);
}
return alias;
}
use of net.sourceforge.squirrel_sql.fw.sql.ISQLAlias in project tdi-studio-se by Talend.
the class SessionTreeNodeUtils method getSessionTreeNode.
public static SessionTreeNode getSessionTreeNode(DatabaseConnection dbconnection, RepositoryNode repositoryNode, String selectedContext) throws Exception {
// hyWang add for bug 0007014
IMetadataConnection iMetadataConnection = null;
iMetadataConnection = ConvertionHelper.convert(dbconnection, false, selectedContext);
String url = dbconnection.getURL();
if (url == null || url.equals("")) {
url = iMetadataConnection.getUrl();
}
// bug 17980
SQLConnection connection = null;
DriverShim wapperDriver = null;
List list = createSQLConnection(dbconnection, selectedContext, iMetadataConnection);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
if (list.get(i) instanceof SQLConnection) {
connection = (SQLConnection) list.get(i);
}
if (list.get(i) instanceof DriverShim) {
wapperDriver = (DriverShim) list.get(i);
}
}
}
ISQLAlias alias = createSQLAlias("Repository Name", url, dbconnection.getUsername(), //$NON-NLS-1$
dbconnection.getRawPassword(), // fix bug for 7014,added by hyWang
dbconnection.getSID() == null || dbconnection.getSID().length() == 0 ? (dbconnection.getDatasourceName() == null || //$NON-NLS-1$
dbconnection.getDatasourceName().length() == 0 ? //$NON-NLS-1$
"Database" : dbconnection.getDatasourceName()) : dbconnection.getSID());
SessionTreeModel stm = new SessionTreeModel();
SessionTreeNode session;
if (wapperDriver != null && (iMetadataConnection.getDriverClass().equals(EDatabase4DriverClassName.JAVADB_EMBEDED.getDriverClass()) || iMetadataConnection.getDbType().equals(EDatabaseTypeName.JAVADB_EMBEDED.getDisplayName()) || iMetadataConnection.getDbType().equals(EDatabaseTypeName.JAVADB_DERBYCLIENT.getDisplayName()) || iMetadataConnection.getDbType().equals(EDatabaseTypeName.JAVADB_JCCJDBC.getDisplayName()) || iMetadataConnection.getDbType().equals(EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName()))) {
session = stm.createSessionTreeNode(new SQLConnection[] { connection, connection }, alias, null, dbconnection.getRawPassword(), repositoryNode, wapperDriver);
} else {
session = stm.createSessionTreeNode(new SQLConnection[] { connection, connection }, alias, null, dbconnection.getRawPassword(), repositoryNode);
}
return session;
}
Aggregations