Search in sources :

Example 1 with SQLExecution

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);
    }
}
Also used : QueryTokenizer(org.talend.sqlbuilder.util.QueryTokenizer) SessionTreeNodeManager(org.talend.sqlbuilder.dbstructure.SessionTreeNodeManager) SessionTreeNode(org.talend.sqlbuilder.sessiontree.model.SessionTreeNode) SQLExecution(org.talend.sqlbuilder.sqlcontrol.SQLExecution) ArrayList(java.util.ArrayList) RepositoryNode(org.talend.repository.model.RepositoryNode)

Aggregations

ArrayList (java.util.ArrayList)1 RepositoryNode (org.talend.repository.model.RepositoryNode)1 SessionTreeNodeManager (org.talend.sqlbuilder.dbstructure.SessionTreeNodeManager)1 SessionTreeNode (org.talend.sqlbuilder.sessiontree.model.SessionTreeNode)1 SQLExecution (org.talend.sqlbuilder.sqlcontrol.SQLExecution)1 QueryTokenizer (org.talend.sqlbuilder.util.QueryTokenizer)1