Search in sources :

Example 1 with SQLScriptProcessor

use of org.jkiss.dbeaver.model.sql.exec.SQLScriptProcessor in project dbeaver by serge-rider.

the class SQLScriptExecuteHandler method processScript.

private void processScript(DBRProgressMonitor monitor, DBTTask task, SQLScriptExecuteSettings settings, DBCExecutionContext executionContext, String filePath, String sqlScriptContent, Log log, PrintStream logStream) throws DBException {
    PrintWriter logWriter = new PrintWriter(logStream, true);
    List<SQLScriptElement> scriptElements = SQLScriptParser.parseScript(executionContext, sqlScriptContent);
    SQLScriptContext scriptContext = new SQLScriptContext(null, () -> executionContext, null, logWriter, null);
    scriptContext.setVariables(DBTaskUtils.getVariables(task));
    SQLScriptDataReceiver dataReceiver = new SQLScriptDataReceiver();
    SQLScriptProcessor scriptProcessor = new SQLScriptProcessor(executionContext, scriptElements, scriptContext, dataReceiver, log);
    scriptProcessor.setCommitType(settings.isAutoCommit() ? SQLScriptCommitType.AUTOCOMMIT : SQLScriptCommitType.AT_END);
    scriptProcessor.setErrorHandling(settings.isIgnoreErrors() ? SQLScriptErrorHandling.IGNORE : SQLScriptErrorHandling.STOP_ROLLBACK);
    if (settings.isDumpQueryResultsToLog()) {
        dataReceiver.setDumpWriter(logWriter);
    }
    scriptProcessor.runScript(monitor);
}
Also used : SQLScriptProcessor(org.jkiss.dbeaver.model.sql.exec.SQLScriptProcessor) SQLScriptElement(org.jkiss.dbeaver.model.sql.SQLScriptElement) SQLScriptContext(org.jkiss.dbeaver.model.sql.SQLScriptContext)

Aggregations

SQLScriptContext (org.jkiss.dbeaver.model.sql.SQLScriptContext)1 SQLScriptElement (org.jkiss.dbeaver.model.sql.SQLScriptElement)1 SQLScriptProcessor (org.jkiss.dbeaver.model.sql.exec.SQLScriptProcessor)1