Search in sources :

Example 11 with JDBCExecutionContext

use of org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext in project dbeaver by serge-rider.

the class MySQLDataSource method setDefaultObject.

@Override
public void setDefaultObject(@NotNull DBRProgressMonitor monitor, @NotNull DBSObject object) throws DBException {
    final MySQLCatalog oldSelectedEntity = getDefaultObject();
    if (!(object instanceof MySQLCatalog)) {
        throw new DBException("Invalid object type: " + object);
    }
    for (JDBCExecutionContext context : getAllContexts()) {
        useDatabase(monitor, context, (MySQLCatalog) object);
    }
    activeCatalogName = object.getName();
    // Send notifications
    if (oldSelectedEntity != null) {
        DBUtils.fireObjectSelect(oldSelectedEntity, false);
    }
    if (this.activeCatalogName != null) {
        DBUtils.fireObjectSelect(object, true);
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) JDBCExecutionContext(org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext)

Example 12 with JDBCExecutionContext

use of org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext in project dbeaver by serge-rider.

the class GenericCatalog method setDefaultObject.

@Override
public void setDefaultObject(@NotNull DBRProgressMonitor monitor, @NotNull DBSObject object) throws DBException {
    final GenericSchema oldSelectedEntity = getDefaultObject();
    //        }
    if (!(object instanceof GenericSchema)) {
        throw new DBException("Bad child type: " + object);
    }
    if (!schemas.contains(GenericSchema.class.cast(object))) {
        throw new DBException("Wrong child object specified as active: " + object);
    }
    GenericDataSource dataSource = getDataSource();
    for (JDBCExecutionContext context : dataSource.getAllContexts()) {
        dataSource.setActiveEntityName(monitor, context, object);
    }
    if (oldSelectedEntity != null) {
        DBUtils.fireObjectSelect(oldSelectedEntity, false);
    }
    DBUtils.fireObjectSelect(object, true);
}
Also used : DBException(org.jkiss.dbeaver.DBException) JDBCExecutionContext(org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext)

Example 13 with JDBCExecutionContext

use of org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext in project dbeaver by dbeaver.

the class MSSQLDataSource method setDefaultObject.

@Override
public void setDefaultObject(DBRProgressMonitor monitor, DBSObject object) throws DBException {
    final MSSQLDatabase oldSelectedEntity = getDefaultObject();
    if (!(object instanceof MSSQLDatabase)) {
        throw new DBException("Invalid object type: " + object);
    }
    for (JDBCExecutionContext context : getAllContexts()) {
        useDatabase(monitor, context, (MSSQLDatabase) object);
    }
    activeDatabaseName = object.getName();
    // Send notifications
    if (oldSelectedEntity != null) {
        DBUtils.fireObjectSelect(oldSelectedEntity, false);
    }
    if (this.activeDatabaseName != null) {
        DBUtils.fireObjectSelect(object, true);
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) JDBCExecutionContext(org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext)

Example 14 with JDBCExecutionContext

use of org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext in project dbeaver by dbeaver.

the class GenericCatalog method setDefaultObject.

@Override
public void setDefaultObject(@NotNull DBRProgressMonitor monitor, @NotNull DBSObject object) throws DBException {
    final GenericSchema oldSelectedEntity = getDefaultObject();
    // }
    if (!(object instanceof GenericSchema)) {
        throw new DBException("Bad child type: " + object);
    }
    if (!schemas.contains(GenericSchema.class.cast(object))) {
        throw new DBException("Wrong child object specified as active: " + object);
    }
    GenericDataSource dataSource = getDataSource();
    for (JDBCExecutionContext context : dataSource.getAllContexts()) {
        dataSource.setActiveEntityName(monitor, context, object);
    }
    if (oldSelectedEntity != null) {
        DBUtils.fireObjectSelect(oldSelectedEntity, false);
    }
    DBUtils.fireObjectSelect(object, true);
}
Also used : DBException(org.jkiss.dbeaver.DBException) JDBCExecutionContext(org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext)

Example 15 with JDBCExecutionContext

use of org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext in project dbeaver by dbeaver.

the class OracleDataSource method setDefaultObject.

@Override
public void setDefaultObject(@NotNull DBRProgressMonitor monitor, @NotNull DBSObject object) throws DBException {
    final OracleSchema oldSelectedEntity = getDefaultObject();
    if (!(object instanceof OracleSchema)) {
        throw new IllegalArgumentException("Invalid object type: " + object);
    }
    for (JDBCExecutionContext context : getAllContexts()) {
        setCurrentSchema(monitor, context, (OracleSchema) object);
    }
    activeSchemaName = object.getName();
    // Send notifications
    if (oldSelectedEntity != null) {
        DBUtils.fireObjectSelect(oldSelectedEntity, false);
    }
    if (this.activeSchemaName != null) {
        DBUtils.fireObjectSelect(object, true);
    }
}
Also used : JDBCExecutionContext(org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext)

Aggregations

JDBCExecutionContext (org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext)17 DBException (org.jkiss.dbeaver.DBException)5 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 DBPConnectionConfiguration (org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)1