use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class DataSourceRegistry method loadDataSources.
private void loadDataSources(InputStream is, DataSourceOrigin origin, boolean refresh, ParseResults parseResults) throws DBException, IOException {
SAXReader parser = new SAXReader(is);
try {
final DataSourcesParser dsp = new DataSourcesParser(origin, refresh, parseResults);
parser.parse(dsp);
} catch (XMLException ex) {
throw new DBException("Datasource config parse error", ex);
}
updateProjectNature();
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class ProjectRegistry method loadProjects.
public void loadProjects(IProgressMonitor monitor) throws DBException {
final DBeaverCore core = DBeaverCore.getInstance();
String activeProjectName = DBeaverCore.getGlobalPreferenceStore().getString(PROP_PROJECT_ACTIVE);
List<IProject> projects = core.getLiveProjects();
monitor.beginTask("Open active project", projects.size());
try {
for (IProject project : projects) {
if (project.exists() && !project.isHidden()) {
if (project.getName().equals(activeProjectName)) {
activeProject = project;
break;
} else if (activeProject == null) {
// By default use first project
activeProject = project;
}
}
monitor.worked(1);
}
if (activeProject != null) {
try {
activeProject.open(monitor);
activeProject.refreshLocal(IFile.DEPTH_ONE, monitor);
setActiveProject(activeProject);
} catch (CoreException e) {
// Project seems to be corrupted
projects.remove(activeProject);
activeProject = null;
}
}
} finally {
monitor.done();
}
if (DBeaverCore.isStandalone() && CommonUtils.isEmpty(projects)) {
// Create initial project (only for standalone version)
monitor.beginTask("Create general project", 1);
try {
activeProject = createGeneralProject(monitor);
activeProject.open(monitor);
setActiveProject(activeProject);
} catch (CoreException e) {
throw new DBException("Can't create default project", e);
} finally {
monitor.done();
}
}
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class DriverDescriptor method loadDriver.
private void loadDriver(DBRProgressMonitor monitor, boolean forceReload) throws DBException {
if (isLoaded && !forceReload) {
return;
}
isLoaded = false;
loadLibraries();
if (!acceptDriverLicenses()) {
throw new DBException("You have to accept driver '" + getFullName() + "' license to be able to connect");
}
try {
if (!isCustomDriverLoader()) {
try {
// Load driver classes into core module using plugin class loader
driverClass = Class.forName(driverClassName, true, classLoader);
} catch (Throwable ex) {
throw new DBException("Can't load driver class '" + driverClassName + "'", ex);
}
// Create driver instance
/*if (!this.isInternalDriver())*/
{
driverInstance = createDriverInstance();
}
isLoaded = true;
isFailed = false;
}
} catch (DBException e) {
isFailed = true;
throw e;
}
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class DataFormatterRegistry method loadProfiles.
private void loadProfiles() {
customProfiles = new ArrayList<>();
File storeFile = DBeaverActivator.getConfigurationFile(CONFIG_FILE_NAME);
if (!storeFile.exists()) {
return;
}
try {
try (InputStream is = new FileInputStream(storeFile)) {
SAXReader parser = new SAXReader(is);
try {
parser.parse(new FormattersParser());
} catch (XMLException ex) {
throw new DBException("Datasource config parse error", ex);
}
} catch (DBException ex) {
log.warn("Can't load profiles config from " + storeFile.getPath(), ex);
}
} catch (IOException ex) {
log.warn("IO error", ex);
}
}
use of org.jkiss.dbeaver.DBException in project dbeaver by serge-rider.
the class DatabaseLazyEditorInput method initializeRealInput.
public IDatabaseEditorInput initializeRealInput(final DBRProgressMonitor monitor) throws DBException {
final DBNModel navigatorModel = DBeaverCore.getInstance().getNavigatorModel();
while (!dataSource.isConnected()) {
boolean connected;
try {
connected = dataSource.connect(monitor, true, true);
} catch (final DBException e) {
// Connection error
final Integer result = new UITask<Integer>() {
@Override
protected Integer runTask() {
ConnectionLostDialog clDialog = new ConnectionLostDialog(DBeaverUI.getActiveWorkbenchShell(), dataSource, e, "Close");
return clDialog.open();
}
}.execute();
if (result == IDialogConstants.STOP_ID) {
// Close editor
return null;
} else if (result == IDialogConstants.RETRY_ID) {
continue;
} else {
return new ErrorEditorInput(GeneralUtils.makeExceptionStatus(e), navigatorModel.getNodeByObject(dataSource));
}
}
if (!connected) {
throw new DBException("Connection to '" + dataSource.getName() + "' canceled");
}
break;
}
try {
DBNDataSource dsNode = (DBNDataSource) navigatorModel.getNodeByObject(monitor, dataSource, true);
if (dsNode == null) {
throw new DBException("Datasource '" + dataSource.getName() + "' navigator node not found");
}
dsNode.initializeNode(monitor, null);
final DBNNode node = navigatorModel.getNodeByPath(monitor, project, nodePath);
if (node == null) {
throw new DBException("Navigator node '" + nodePath + "' not found");
}
if (node instanceof DBNDatabaseNode) {
EntityEditorInput realInput = new EntityEditorInput((DBNDatabaseNode) node);
realInput.setDefaultFolderId(activeFolderId);
realInput.setDefaultPageId(activePageId);
return realInput;
} else {
throw new DBException("Database node has bad type: " + node.getClass().getName());
}
} catch (DBException e) {
return new ErrorEditorInput(GeneralUtils.makeExceptionStatus(e), navigatorModel.getNodeByObject(dataSource));
}
}
Aggregations