package eu.etaxonomy.taxeditor.view.datasource.handler;
+import java.sql.SQLException;
+
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.jface.viewers.ISelection;
return null;
}
- if(!container.isRunning()){
+ try {
+ container.getDataSource().testConnection();
+ boolean confirmed = StoreUtil.confirmDialog("Confirm Datasource Connection", "Do you really want to connect to this datasource?\n\n"
+ + container.getDataSource().getName());
+
+ if(confirmed){
+ CdmDataSourceRepository.changeDataSource(container.getDataSource());
+ }
+ } catch (Exception e) {
StoreUtil.warningDialog("Chosen datasource is not available", this, "This could mean that either the database server is " +
"not running or the machine is not reachable.\n\n" +
"Please also make sure that you are connected to the network when trying to connect to a remote datasource.");
+ StoreUtil.warn(getClass(), e);
return null;
- }
-
- boolean confirmed = StoreUtil.confirmDialog("Confirm Datasource Connection", "Do you really want to connect to this datasource?\n\n"
- + container.getDataSource().getName());
-
- if(confirmed){
- CdmDataSourceRepository.changeDataSource(container.getDataSource());
- }
+ }
}
return null;