use of org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext in project dbeaver by dbeaver.
the class PostgreDataSource method setDefaultObject.
@Override
public void setDefaultObject(@NotNull DBRProgressMonitor monitor, @NotNull DBSObject object) throws DBException {
final PostgreDatabase oldDatabase = getDefaultObject();
if (!(object instanceof PostgreDatabase)) {
throw new IllegalArgumentException("Invalid object type: " + object);
}
final PostgreDatabase newDatabase = (PostgreDatabase) object;
if (oldDatabase == newDatabase) {
// The same
return;
}
// FIXME: make real target database change
// 1. Check active transactions
// 2. Reconnect all open contexts
// 3. Refresh datasource tree
activeDatabaseName = object.getName();
for (JDBCExecutionContext context : getAllContexts()) {
context.reconnect(monitor);
}
getDefaultInstance().cacheDataTypes(monitor);
// Update database name and URL in connection settings and save datasources
DBPConnectionConfiguration conConfig = getContainer().getConnectionConfiguration();
conConfig.setDatabaseName(activeDatabaseName);
conConfig.setUrl(getContainer().getDriver().getDataSourceProvider().getConnectionURL(getContainer().getDriver(), conConfig));
getContainer().getRegistry().flushConfig();
// Notify UI
if (oldDatabase != null) {
DBUtils.fireObjectSelect(oldDatabase, false);
DBUtils.fireObjectUpdate(oldDatabase, false);
}
DBUtils.fireObjectSelect(newDatabase, true);
DBUtils.fireObjectUpdate(newDatabase, true);
}
use of org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext in project dbeaver by dbeaver.
the class PostgreDatabase method setDefaultObject.
@Override
public void setDefaultObject(@NotNull DBRProgressMonitor monitor, @NotNull DBSObject object) throws DBException {
if (object instanceof PostgreSchema) {
PostgreSchema oldActive = getDefaultObject();
if (oldActive == object) {
return;
}
for (JDBCExecutionContext context : dataSource.getAllContexts()) {
setSearchPath(monitor, (PostgreSchema) object, context);
}
dataSource.setActiveSchemaName(object.getName());
dataSource.setSearchPath(object.getName());
if (oldActive != null) {
DBUtils.fireObjectSelect(oldActive, false);
}
DBUtils.fireObjectSelect(object, true);
}
}
use of org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext in project dbeaver by serge-rider.
the class DB2DataSource method setDefaultObject.
@Override
public void setDefaultObject(@NotNull DBRProgressMonitor monitor, @NotNull DBSObject object) throws DBException {
final DB2Schema oldSelectedEntity = getDefaultObject();
if (!(object instanceof DB2Schema)) {
throw new IllegalArgumentException("Invalid object type: " + object);
}
for (JDBCExecutionContext context : getAllContexts()) {
setCurrentSchema(monitor, context, (DB2Schema) object);
}
activeSchemaName = object.getName();
// Send notifications
if (oldSelectedEntity != null) {
DBUtils.fireObjectSelect(oldSelectedEntity, false);
}
if (this.activeSchemaName != null) {
DBUtils.fireObjectSelect(object, true);
}
}
use of org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext in project dbeaver by serge-rider.
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);
}
}
use of org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext in project dbeaver by serge-rider.
the class PostgreDatabase method setDefaultObject.
@Override
public void setDefaultObject(@NotNull DBRProgressMonitor monitor, @NotNull DBSObject object) throws DBException {
if (object instanceof PostgreSchema) {
PostgreSchema oldActive = getDefaultObject();
if (oldActive == object) {
return;
}
for (JDBCExecutionContext context : dataSource.getAllContexts()) {
setSearchPath(monitor, (PostgreSchema) object, context);
}
dataSource.setActiveSchemaName(object.getName());
dataSource.setSearchPath(object.getName());
if (oldActive != null) {
DBUtils.fireObjectSelect(oldActive, false);
}
DBUtils.fireObjectSelect(object, true);
}
}
Aggregations