use of org.talend.sqlbuilder.sqlcontrol.SQLExecution in project tdi-studio-se by Talend.
the class ExecSQLAction method run.
/**
* DOC qianbing Comment method "run". Processes the database operation.
*
* @param maxRows
*/
protected void run(int maxRows) {
RepositoryNode node = editor.getRepositoryNode();
SessionTreeNodeManager nodeManager = new SessionTreeNodeManager();
SessionTreeNode runNode = null;
try {
ConnectionContextHelper.setSqlBuilderDialogShell(editor.getDialog().getShell());
runNode = nodeManager.getSessionTreeNode(node, editor.getDialog().getSelectedContext());
} catch (Exception e) {
// e.printStackTrace();
ExceptionHandler.process(e);
//$NON-NLS-1$
MessageDialog.openError(null, Messages.getString("AbstractSQLExecution.Executing.Error"), e.getMessage());
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("ExecSQLAction.logMessageGetSessionTreeNodeFail"), e);
return;
}
QueryTokenizer qt = new QueryTokenizer(getSQLToBeExecuted(), queryDelimiter, alternateDelimiter, commentDelimiter);
List<String> queryStrings = new ArrayList<String>();
while (qt.hasQuery()) {
String querySql = qt.nextQuery();
// ignore commented lines.
if (!querySql.startsWith("--")) {
//$NON-NLS-1$
queryStrings.add(querySql);
}
}
try {
// Diaplay data in sqlResult Composites
while (!queryStrings.isEmpty()) {
String querySql = queryStrings.remove(0);
if (querySql != null) {
SQLExecution sqlExe = new SQLExecution(querySql, maxRows, runNode);
resultViewer.addSQLExecution(sqlExe);
// editor.setSQLRunTime(sqlExe.getSQLResult().getExecutionTimeMillis());
}
}
} catch (Exception e) {
// e.printStackTrace();
ExceptionHandler.process(e);
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("ExecSQLAction.logMessageErrorCreatingSqlTab"), e);
}
}
Aggregations