提交 ce85ec68 编写于 作者: S serge-rider

Merge remote-tracking branch 'origin/devel' into devel

......@@ -391,11 +391,13 @@ public class CoreMessages extends NLS {
public static String dialog_edit_driver_dialog_open_driver_library;
public static String dialog_edit_driver_label_category;
public static String dialog_edit_driver_label_class_name;
public static String dialog_edit_driver_label_class_name_tip;
public static String dialog_edit_driver_label_default_port;
public static String dialog_edit_driver_label_description;
public static String dialog_edit_driver_label_driver_class;
public static String dialog_edit_driver_label_driver_name;
public static String dialog_edit_driver_label_sample_url;
public static String dialog_edit_driver_label_sample_url_tip;
public static String dialog_edit_driver_label_website;
public static String dialog_edit_driver_tab_name_advanced_parameters;
public static String dialog_edit_driver_tab_name_connection_properties;
......
......@@ -443,11 +443,13 @@ dialog_edit_driver_dialog_open_driver_directory = Open driver directory
dialog_edit_driver_dialog_open_driver_library = Open driver library
dialog_edit_driver_label_category = Category
dialog_edit_driver_label_class_name = Class Name
dialog_edit_driver_label_class_name_tip = Java class name of driver implementation.\nClick "Find Class" button to find classes present in libraries.\nIf empty then DBeaver won't instantiate driver and will use JDBC instead.
dialog_edit_driver_label_default_port = Default Port
dialog_edit_driver_label_description = Description
dialog_edit_driver_label_driver_class = Driver class
dialog_edit_driver_label_driver_name = Driver Name
dialog_edit_driver_label_sample_url = URL Template
dialog_edit_driver_label_sample_url_tip = Template which will be used to construct connection URL. Not required for non-JDBC drivers.\nIf empty you will need to specify JDBC URL for each connection.
dialog_edit_driver_label_website = Website
dialog_edit_driver_tab_name_advanced_parameters = Adv. parameters
dialog_edit_driver_tab_name_client_homes = Native Client
......
......@@ -627,11 +627,15 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
}
@Override
public boolean isCustomDriverLoader()
{
public boolean isCustomDriverLoader() {
return customDriverLoader;
}
@Override
public boolean isInstantiable() {
return !CommonUtils.isEmpty(driverClassName);
}
@Nullable
@Override
public DBXTreeNode getNavigatorRoot() {
......
......@@ -22,8 +22,8 @@ package org.jkiss.dbeaver.ui;
public interface IHelpContextIds
{
String CTX_DRIVER_MANAGER = "driver-manager"; //$NON-NLS-1$
String CTX_DRIVER_EDITOR = "driver-editor"; //$NON-NLS-1$
String CTX_DRIVER_MANAGER = "database-drivers"; //$NON-NLS-1$
String CTX_DRIVER_EDITOR = "database-drivers"; //$NON-NLS-1$
String CTX_SQL_EDITOR = "sql-editor"; //$NON-NLS-1$
String CTX_RESULT_SET_VIEWER = "result-set-viewer"; //$NON-NLS-1$
......
......@@ -99,7 +99,7 @@ public class DriverEditDialog extends HelpEnabledDialog {
private boolean showAddFiles = false;
public static int getDialogCount() {
static int getDialogCount() {
return dialogCount;
}
......@@ -112,7 +112,7 @@ public class DriverEditDialog extends HelpEnabledDialog {
this.origLibList = new ArrayList<>(driver.getDriverLibraries());
}
public DriverEditDialog(Shell shell, DataSourceProviderDescriptor provider, String category) {
DriverEditDialog(Shell shell, DataSourceProviderDescriptor provider, String category) {
super(shell, IHelpContextIds.CTX_DRIVER_EDITOR);
this.provider = provider;
this.driver = provider.createDriver();
......@@ -121,7 +121,7 @@ public class DriverEditDialog extends HelpEnabledDialog {
this.origLibList = new ArrayList<>();
}
public DriverEditDialog(Shell shell, DataSourceProviderDescriptor provider, DriverDescriptor driver) {
DriverEditDialog(Shell shell, DataSourceProviderDescriptor provider, DriverDescriptor driver) {
super(shell, IHelpContextIds.CTX_DRIVER_EDITOR);
this.provider = provider;
this.driver = provider.createDriver(driver);
......@@ -222,10 +222,12 @@ public class DriverEditDialog extends HelpEnabledDialog {
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 3;
driverClassText = UIUtils.createLabelText(propsGroup, CoreMessages.dialog_edit_driver_label_class_name + "*", CommonUtils.notEmpty(driver.getDriverClassName()), SWT.BORDER | advStyle, gd);
driverClassText = UIUtils.createLabelText(propsGroup, CoreMessages.dialog_edit_driver_label_class_name, CommonUtils.notEmpty(driver.getDriverClassName()), SWT.BORDER | advStyle, gd);
driverClassText.setToolTipText(CoreMessages.dialog_edit_driver_label_class_name_tip);
driverClassText.addModifyListener(e -> onChangeProperty());
driverURLText = UIUtils.createLabelText(propsGroup, CoreMessages.dialog_edit_driver_label_sample_url, CommonUtils.notEmpty(driver.getSampleURL()), SWT.BORDER | advStyle, gd);
driverURLText.setToolTipText(CoreMessages.dialog_edit_driver_label_sample_url_tip);
driverURLText.addModifyListener(e -> onChangeProperty());
gd = new GridData(GridData.FILL_HORIZONTAL);
......@@ -704,9 +706,8 @@ public class DriverEditDialog extends HelpEnabledDialog {
private void onChangeProperty() {
Button button = getButton(IDialogConstants.OK_ID);
if (button != null) {
button.setEnabled(
!CommonUtils.isEmpty(driverNameText.getText()) &&
!CommonUtils.isEmpty(driverClassText.getText()));
boolean isValid = !CommonUtils.isEmpty(driverNameText.getText());
button.setEnabled(isValid);
}
}
......@@ -818,7 +819,7 @@ public class DriverEditDialog extends HelpEnabledDialog {
private final DBPDataSource dataSource;
public BadDriverConfigDialog(Shell shell, String title, String message, DBException error) {
BadDriverConfigDialog(Shell shell, String title, String message, DBException error) {
super(
shell == null ? DBeaverUI.getActiveWorkbenchShell() : shell,
title,
......@@ -886,10 +887,8 @@ public class DriverEditDialog extends HelpEnabledDialog {
@Override
public boolean hasChildren(Object element) {
if (element instanceof DBPDriverLibrary) {
return !CommonUtils.isEmpty(driver.getLibraryFiles((DBPDriverLibrary) element));
}
return false;
return element instanceof DBPDriverLibrary &&
!CommonUtils.isEmpty(driver.getLibraryFiles((DBPDriverLibrary) element));
}
}
}
......@@ -81,6 +81,7 @@ public interface DBPDriver extends DBPNamedObject
boolean isEmbedded();
boolean isAnonymousAccess();
boolean isCustomDriverLoader();
boolean isInstantiable();
boolean isInternalDriver();
@Nullable
......@@ -119,5 +120,4 @@ public interface DBPDriver extends DBPNamedObject
Object getDriverInstance(@NotNull DBRProgressMonitor monitor) throws DBException;
void loadDriver(DBRProgressMonitor monitor) throws DBException;
}
......@@ -115,11 +115,13 @@ public abstract class JDBCDataSource
throws DBCException
{
// It MUST be a JDBC driver
Driver driverInstance;
try {
driverInstance = getDriverInstance(monitor);
} catch (DBException e) {
throw new DBCConnectException("Can't create driver instance", e, this);
Driver driverInstance = null;
if (getContainer().getDriver().isInstantiable()) {
try {
driverInstance = getDriverInstance(monitor);
} catch (DBException e) {
throw new DBCConnectException("Can't create driver instance", e, this);
}
}
DBPConnectionConfiguration connectionInfo = container.getActualConnectionConfiguration();
......@@ -142,13 +144,14 @@ public abstract class JDBCDataSource
Connection[] connection = new Connection[1];
Exception[] error = new Exception[1];
int openTimeout = getContainer().getPreferenceStore().getInt(ModelPreferences.CONNECTION_OPEN_TIMEOUT);
final Driver driverInstanceFinal = driverInstance;
boolean openTaskFinished = RuntimeUtils.runTask(monitor1 -> {
try {
if (driverInstance == null) {
if (driverInstanceFinal == null) {
connection[0] = DriverManager.getConnection(url, connectProps);
} else {
connection[0] = driverInstance.connect(url, connectProps);
connection[0] = driverInstanceFinal.connect(url, connectProps);
}
} catch (Exception e) {
error[0] = e;
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
* Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -1654,13 +1654,13 @@ public class JDBCResultSetImpl implements JDBCResultSet {
@Nullable
@Override
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
return JDBCUtils.callMethod17(getOriginal(), "getObject", type, new Class<?>[] {Integer.TYPE, Class.class}, columnIndex, type);
return original.getObject(columnIndex, type);
}
@Nullable
@Override
public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
return JDBCUtils.callMethod17(getOriginal(), "getObject", type, new Class<?>[] {String.class, Class.class}, columnLabel, type);
return original.getObject(columnLabel, type);
}
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册