APISonar


org.jkiss.dbeaver.model.exec.DBCExecutionPurpose.UTIL

> org > jkiss > dbeaver > model > exec > DBCExecutionPurpose > UTIL
org APIs jkiss APIs dbeaver APIs model APIs exec APIs DBCExecutionPurpose APIs UTIL APIs

Example 1
public Object extractEditorValue() throws DBCException {
        try (DBCSession session = valueController.getExecutionContext().openSession(new VoidProgressMonitor(), DBCExecutionPurpose.UTIL, "Make string value from editor")) {
            String text;
            if (control instanceof Text) {
                text = ((Text) control).getText();
            } else {
                text = ((StyledText) control).getText();
            }
            return valueController.getValueHandler().getValueFromObject(
                session,
                valueController.getValueType(),
                text,
                false);
        }
    }
Example 2
public void removeBreakpoint(DBRProgressMonitor monitor, DBGBreakpointDescriptor bp) throws DBGException {
        try (JDBCSession session = getControllerConnection().openSession(monitor, DBCExecutionPurpose.UTIL, "Remove breakpoint")) {
            try (Statement stmt = session.createStatement()) {
                String sqlCommand = composeRemoveBreakpointCommand(bp);
                stmt.execute(sqlCommand);
            } catch (SQLException e) {
                throw new DBGException("SQL error", e);
            }
            breakpoints.remove(bp);
        }
    }
Example 3
public void addBreakpoint(DBRProgressMonitor monitor, DBGBreakpointDescriptor descriptor) throws DBGException {
        try (JDBCSession session = getControllerConnection().openSession(monitor, DBCExecutionPurpose.UTIL, "Add breakpoint")) {
            try (Statement stmt = session.createStatement()) {
                String sqlQuery = composeAddBreakpointCommand(descriptor);
                stmt.execute(sqlQuery);
            } catch (SQLException e) {
                throw new DBGException("SQL error", e);
            }
            breakpoints.add(descriptor);
        }
    }
Example 4
public static String getMessageFromCode(DB2DataSource db2DataSource, Integer sqlErrorCode) throws SQLException
    {
        JDBCSession session = db2DataSource.getDefaultContext(false).openSession(VoidProgressMonitor.INSTANCE, DBCExecutionPurpose.UTIL, "Get Error Code");
        return JDBCUtils.queryString(session, GET_MSG, sqlErrorCode);
    }
Example 5
public void checkInstanceConnection(DBRProgressMonitor monitor) throws DBException {
        if (executionContext == null) {
            initializeMainContext(monitor);
            initializeMetaContext(monitor);

            try (JDBCSession session = getDefaultContext(true).openSession(monitor, DBCExecutionPurpose.UTIL, "Detect default schema/user")) {
                determineDefaultObjects(session);
            } catch (SQLException e) {
                throw new DBException(e, getDataSource());
            }
        }
    }
Example 6
void setActiveEntityName(DBRProgressMonitor monitor, DBSObject entity) throws DBException
    {
        if (entity instanceof CassandraKeyspace) {
            JDBCSession session = openSession(monitor, DBCExecutionPurpose.UTIL, "Set active catalog");
            try {
                session.setSchema(entity.getName());
                selectedKeyspace = entity.getName();
            } catch (SQLException e) {
                throw new DBException(e, session.getDataSource());
            }
            finally {
                session.close();
            }
        }
    }
Example 7
private boolean checkDebugPlagin(DBRProgressMonitor monitor) {
        try (JDBCSession session = getControllerConnection().openSession(monitor, DBCExecutionPurpose.UTIL, "Check debug plugin installation")) {
            String version = JDBCUtils.executeQuery(session, SQL_CHECK_PLUGIN);
            log.debug("Debug plugin is installed:\n" + version);
            return true;
        } catch (Exception e) {
            log.debug("Debug plugin not installed: " + e.getMessage());
            return false;
        }
    }
Example 8
public Object extractEditorValue() throws DBException {
        try (DBCSession session = valueController.getExecutionContext().openSession(VoidProgressMonitor.INSTANCE, DBCExecutionPurpose.UTIL, "Make datetime value from editor")) {
            final String strValue = timeEditor.getValue();
            return valueController.getValueHandler().getValueFromObject(session, valueController.getValueType(), strValue, false);
        }
    }
Example 9
public static void callAdminCmd(DBRProgressMonitor monitor, DB2DataSource dataSource, String command) throws SQLException
    {
        LOG.debug("Call admin_cmd with '" + command + "'");
        String sql = String.format(CALL_ADMIN_CMD, command);

        monitor.beginTask("Executing command " + command, 1);

        JDBCSession session = dataSource.getDefaultContext(false).openSession(monitor, DBCExecutionPurpose.UTIL, "ADMIN_CMD");
        try {
            JDBCUtils.executeProcedure(session, sql);
        } finally {
            session.close();
            monitor.done();
        }
    }
Example 10
private void detachGlobal(DBRProgressMonitor monitor) throws DBGException {
        removeBreakpoint(monitor, bpGlobal);

        try (JDBCSession session = getControllerConnection().openSession(monitor, DBCExecutionPurpose.UTIL, "Abort global session")) {
            JDBCUtils.executeQuery(session, composeAbortCommand());
            log.debug("Global deattached");
        } catch (SQLException e) {
            log.error("Unable to abort global target", e);
        }
    }
Example 11
private void setCurrentDatabase(DBRProgressMonitor monitor, JDBCExecutionContext executionContext, SQLServerDatabase object) throws DBCException {
        if (object == null) {
            log.debug("Null current schema");
            return;
        }
        try (JDBCSession session = executionContext.openSession(monitor, DBCExecutionPurpose.UTIL, "Set active database")) {
            SQLServerUtils.setCurrentDatabase(session, object.getName());
        } catch (SQLException e) {
            throw new DBCException(e, this);
        }
    }
Example 12
private void detachLocal(DBRProgressMonitor monitor, JDBCExecutionContext connection) throws DBGException {
        if (localStatement == null) {
            // Execution already terminated
            return;
        }
        try (JDBCSession session = connection.openSession(monitor, DBCExecutionPurpose.UTIL, "Abort local session")) {
            JDBCUtils.executeQuery(session, composeAbortCommand());
            log.debug("Local detached");
        } catch (SQLException e) {
            log.debug("Unable to abort local session");
            log.error("Unable to abort local target", e);
        }
    }
Example 13
void setSearchPath(DBRProgressMonitor monitor, PostgreSchema schema, JDBCExecutionContext context) throws DBCException {
        try (JDBCSession session = context.openSession(monitor, DBCExecutionPurpose.UTIL, "Change search path")) {
            JDBCUtils.executeSQL(session, "SET search_path = \"$user\"," + DBUtils.getQuotedIdentifier(schema));
        } catch (SQLException e) {
            throw new DBCException("Error setting search path", e, dataSource);
        }
    }