Search in sources :

Example 1 with DBGVariable

use of org.jkiss.dbeaver.debug.DBGVariable in project dbeaver by dbeaver.

the class PostgreDebugSession method getVariables.

@Override
public List<DBGVariable<?>> getVariables() throws DBGException {
    acquireReadLock();
    List<DBGVariable<?>> vars = new ArrayList<>();
    String sql = SQL_GET_VARS.replaceAll("\\?sessionid", String.valueOf(sessionId));
    try (Statement stmt = getConnection().createStatement();
        ResultSet rs = stmt.executeQuery(sql)) {
        while (rs.next()) {
            String name = rs.getString("name");
            String varclass = rs.getString("varclass");
            int linenumber = rs.getInt("linenumber");
            boolean isunique = rs.getBoolean("isunique");
            boolean isconst = rs.getBoolean("isconst");
            boolean isnotnull = rs.getBoolean("isnotnull");
            int dtype = rs.getInt("dtype");
            String value = rs.getString("value");
            PostgreDebugVariable var = new PostgreDebugVariable(name, varclass, linenumber, isunique, isconst, isnotnull, dtype, value);
            vars.add(var);
        }
    } catch (SQLException e) {
        throw new DBGException("SQL error", e);
    } finally {
        lock.readLock().unlock();
    }
    return vars;
}
Also used : DBGException(org.jkiss.dbeaver.debug.DBGException) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) DBGVariable(org.jkiss.dbeaver.debug.DBGVariable)

Aggregations

PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 ArrayList (java.util.ArrayList)1 DBGException (org.jkiss.dbeaver.debug.DBGException)1 DBGVariable (org.jkiss.dbeaver.debug.DBGVariable)1