diff --git a/build.gradle b/build.gradle
index 96a2fedc716..c7acea3a3bc 100644
--- a/build.gradle
+++ b/build.gradle
@@ -193,6 +193,10 @@ dependencies {
implementation 'org.postgresql:postgresql:42.7.3'
+ // Support unix socket connection types
+ implementation 'com.kohlschutter.junixsocket:junixsocket-core:2.9.1'
+ implementation 'com.kohlschutter.junixsocket:junixsocket-mysql:2.9.1'
+
implementation ('com.oracle.ojdbc:ojdbc10:19.3.0.0') {
// causing module issues
exclude module: 'oraclepki'
diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialog.fxml b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialog.fxml
index 04121fb296b..ed0ca01a216 100644
--- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialog.fxml
+++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialog.fxml
@@ -35,6 +35,8 @@
+
+
@@ -67,6 +69,11 @@
+
+
+
+
diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java
index b43c748cfc0..14067e2c397 100644
--- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java
+++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java
@@ -47,6 +47,8 @@ public class SharedDatabaseLoginDialogView extends BaseDialog {
@FXML private PasswordField passwordKeystore;
@FXML private Button browseKeystore;
@FXML private TextField serverTimezone;
+ @FXML private TextField jdbcUrl;
+ @FXML private CheckBox expertMode;
@Inject private DialogService dialogService;
@Inject private PreferencesService preferencesService;
@@ -117,6 +119,10 @@ private void initialize() {
fileKeystore.textProperty().bindBidirectional(viewModel.keyStoreProperty());
+ expertMode.selectedProperty().bindBidirectional(viewModel.expertModeProperty());
+ jdbcUrl.textProperty().bindBidirectional(viewModel.jdbcUrlProperty());
+ jdbcUrl.disableProperty().bind(viewModel.expertModeProperty().not());
+
browseKeystore.disableProperty().bind(viewModel.useSSLProperty().not());
passwordKeystore.disableProperty().bind(viewModel.useSSLProperty().not());
passwordKeystore.textProperty().bindBidirectional(viewModel.keyStorePasswordProperty());
diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java
index 6505d7ca028..91ffd261a41 100644
--- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java
@@ -76,6 +76,8 @@ public class SharedDatabaseLoginDialogViewModel extends AbstractViewModel {
private final BooleanProperty useSSL = new SimpleBooleanProperty();
private final StringProperty keyStorePasswordProperty = new SimpleStringProperty("");
private final StringProperty serverTimezone = new SimpleStringProperty("");
+ private final BooleanProperty expertMode = new SimpleBooleanProperty();
+ private final StringProperty jdbcUrl = new SimpleStringProperty("");
private final LibraryTabContainer tabContainer;
private final DialogService dialogService;
@@ -144,6 +146,8 @@ public boolean openDatabase() {
.setAllowPublicKeyRetrieval(true)
.setKeyStore(keystore.getValue())
.setServerTimezone(serverTimezone.getValue())
+ .setExpertMode(expertMode.getValue())
+ .setJdbcUrl(jdbcUrl.getValue())
.createDBMSConnectionProperties();
setupKeyStore();
@@ -403,4 +407,12 @@ public ValidationStatus formValidation() {
public StringProperty serverTimezoneProperty() {
return serverTimezone;
}
+
+ public BooleanProperty expertModeProperty() {
+ return expertMode;
+ }
+
+ public StringProperty jdbcUrlProperty() {
+ return jdbcUrl;
+ }
}
diff --git a/src/main/java/org/jabref/logic/shared/DBMSConnection.java b/src/main/java/org/jabref/logic/shared/DBMSConnection.java
index a37f1d9532d..a01f83a8481 100644
--- a/src/main/java/org/jabref/logic/shared/DBMSConnection.java
+++ b/src/main/java/org/jabref/logic/shared/DBMSConnection.java
@@ -30,11 +30,16 @@ public DBMSConnection(DBMSConnectionProperties connectionProperties) throws SQLE
// ensure that all SQL drivers are loaded - source: http://stackoverflow.com/a/22384826/873282
// we use the side effect of getAvailableDBMSTypes() - it loads all available drivers
DBMSConnection.getAvailableDBMSTypes();
- this.connection = DriverManager.getConnection(connectionProperties.getUrl(), connectionProperties.asProperties());
+
+ if (connectionProperties.isUseExpertMode()) {
+ this.connection = DriverManager.getConnection(connectionProperties.getJdbcUrl(), connectionProperties.asProperties());
+ } else {
+ this.connection = DriverManager.getConnection(connectionProperties.getUrl(), connectionProperties.asProperties());
+ }
} catch (SQLException e) {
// Some systems like PostgreSQL retrieves 0 to every exception.
// Therefore a stable error determination is not possible.
- LOGGER.error("Could not connect to database: " + e.getMessage() + " - Error code: " + e.getErrorCode());
+ LOGGER.error("Could not connect to database: {} - Error code: {}", e.getMessage(), e.getErrorCode());
throw e;
}
}
diff --git a/src/main/java/org/jabref/logic/shared/DBMSConnectionProperties.java b/src/main/java/org/jabref/logic/shared/DBMSConnectionProperties.java
index 86675fc2e9b..acfe8f9250b 100644
--- a/src/main/java/org/jabref/logic/shared/DBMSConnectionProperties.java
+++ b/src/main/java/org/jabref/logic/shared/DBMSConnectionProperties.java
@@ -26,8 +26,10 @@ public class DBMSConnectionProperties implements DatabaseConnectionProperties {
private String user;
private String password;
private boolean allowPublicKeyRetrieval;
- private boolean useSSL;
+ private final boolean useSSL;
private String serverTimezone = "";
+ private String jdbcUrl = "";
+ private final boolean expertMode;
// Not needed for connection, but stored for future login
private String keyStore;
@@ -38,9 +40,7 @@ public class DBMSConnectionProperties implements DatabaseConnectionProperties {
public DBMSConnectionProperties(SharedDatabasePreferences prefs) {
if (prefs.getType().isPresent()) {
Optional dbmsType = DBMSType.fromString(prefs.getType().get());
- if (dbmsType.isPresent()) {
- this.type = dbmsType.get();
- }
+ dbmsType.ifPresent(value -> this.type = value);
}
prefs.getHost().ifPresent(theHost -> this.host = theHost);
@@ -48,6 +48,9 @@ public DBMSConnectionProperties(SharedDatabasePreferences prefs) {
prefs.getName().ifPresent(theDatabase -> this.database = theDatabase);
prefs.getKeyStoreFile().ifPresent(theKeystore -> this.keyStore = theKeystore);
prefs.getServerTimezone().ifPresent(theServerTimezone -> this.serverTimezone = theServerTimezone);
+ prefs.getJdbcUrl().ifPresent(theJdbcUrl -> this.jdbcUrl = theJdbcUrl);
+
+ this.expertMode = prefs.isUseExpertMode();
this.useSSL = prefs.isUseSSL();
if (prefs.getUser().isPresent()) {
@@ -61,14 +64,15 @@ public DBMSConnectionProperties(SharedDatabasePreferences prefs) {
}
}
- if (!prefs.getPassword().isPresent()) {
+ if (prefs.getPassword().isEmpty()) {
// Some DBMS require a non-null value as a password (in case of using an empty string).
this.password = "";
}
}
DBMSConnectionProperties(DBMSType type, String host, int port, String database, String user,
- String password, boolean useSSL, boolean allowPublicKeyRetrieval, String serverTimezone, String keyStore) {
+ String password, boolean useSSL, boolean allowPublicKeyRetrieval,
+ String serverTimezone, String keyStore, String jdbcUrl, boolean expertMode) {
this.type = type;
this.host = host;
this.port = port;
@@ -79,6 +83,8 @@ public DBMSConnectionProperties(SharedDatabasePreferences prefs) {
this.allowPublicKeyRetrieval = allowPublicKeyRetrieval;
this.serverTimezone = serverTimezone;
this.keyStore = keyStore;
+ this.jdbcUrl = jdbcUrl;
+ this.expertMode = expertMode;
}
@Override
@@ -126,9 +132,18 @@ public String getServerTimezone() {
return serverTimezone;
}
+ @Override
+ public String getJdbcUrl() {
+ return jdbcUrl;
+ }
+
+ @Override
+ public boolean isUseExpertMode() {
+ return expertMode;
+ }
+
public String getUrl() {
- String url = type.getUrl(host, port, database);
- return url;
+ return type.getUrl(host, port, database);
}
/**
@@ -142,11 +157,11 @@ public Properties asProperties() {
props.setProperty("password", password);
props.setProperty("serverTimezone", serverTimezone);
if (useSSL) {
- props.setProperty("ssl", Boolean.toString(useSSL));
- props.setProperty("useSSL", Boolean.toString(useSSL));
+ props.setProperty("ssl", Boolean.toString(true));
+ props.setProperty("useSSL", Boolean.toString(true));
}
if (allowPublicKeyRetrieval) {
- props.setProperty("allowPublicKeyRetrieval", Boolean.toString(allowPublicKeyRetrieval));
+ props.setProperty("allowPublicKeyRetrieval", Boolean.toString(true));
}
return props;
}
@@ -165,10 +180,9 @@ public boolean equals(Object obj) {
return true;
}
- if (!(obj instanceof DBMSConnectionProperties)) {
+ if (!(obj instanceof DBMSConnectionProperties properties)) {
return false;
}
- DBMSConnectionProperties properties = (DBMSConnectionProperties) obj;
return Objects.equals(type, properties.getType())
&& this.host.equalsIgnoreCase(properties.getHost())
&& Objects.equals(port, properties.getPort())
@@ -176,12 +190,15 @@ public boolean equals(Object obj) {
&& Objects.equals(user, properties.getUser())
&& Objects.equals(useSSL, properties.isUseSSL())
&& Objects.equals(allowPublicKeyRetrieval, properties.isAllowPublicKeyRetrieval())
- && Objects.equals(serverTimezone, properties.getServerTimezone());
+ && Objects.equals(serverTimezone, properties.getServerTimezone())
+ && Objects.equals(keyStore, properties.getKeyStore())
+ && Objects.equals(jdbcUrl, properties.getJdbcUrl())
+ && Objects.equals(expertMode, properties.isUseExpertMode());
}
@Override
public int hashCode() {
- return Objects.hash(type, host, port, database, user, useSSL);
+ return Objects.hash(type, host, port, database, user, useSSL, allowPublicKeyRetrieval, serverTimezone, keyStore, jdbcUrl, expertMode);
}
@Override
diff --git a/src/main/java/org/jabref/logic/shared/DBMSConnectionPropertiesBuilder.java b/src/main/java/org/jabref/logic/shared/DBMSConnectionPropertiesBuilder.java
index 3547358dee8..95ef884d058 100644
--- a/src/main/java/org/jabref/logic/shared/DBMSConnectionPropertiesBuilder.java
+++ b/src/main/java/org/jabref/logic/shared/DBMSConnectionPropertiesBuilder.java
@@ -11,6 +11,8 @@ public class DBMSConnectionPropertiesBuilder {
private boolean allowPublicKeyRetrieval;
private String serverTimezone = "";
private String keyStore;
+ private boolean expertMode = false;
+ private String jdbcUrl = "";
public DBMSConnectionPropertiesBuilder setType(DBMSType type) {
this.type = type;
@@ -62,10 +64,20 @@ public DBMSConnectionPropertiesBuilder setKeyStore(String keyStore) {
return this;
}
+ public DBMSConnectionPropertiesBuilder setJdbcUrl(String jdbcUrl) {
+ this.jdbcUrl = jdbcUrl;
+ return this;
+ }
+
+ public DBMSConnectionPropertiesBuilder setExpertMode(boolean expertMode) {
+ this.expertMode = expertMode;
+ return this;
+ }
+
public DBMSConnectionProperties createDBMSConnectionProperties() {
if (port == -1) {
port = type.getDefaultPort();
}
- return new DBMSConnectionProperties(type, host, port, database, user, password, useSSL, allowPublicKeyRetrieval, serverTimezone, keyStore);
+ return new DBMSConnectionProperties(type, host, port, database, user, password, useSSL, allowPublicKeyRetrieval, serverTimezone, keyStore, jdbcUrl, expertMode);
}
}
diff --git a/src/main/java/org/jabref/logic/shared/DBMSType.java b/src/main/java/org/jabref/logic/shared/DBMSType.java
index 1cd6774ce60..8a3717abaf0 100644
--- a/src/main/java/org/jabref/logic/shared/DBMSType.java
+++ b/src/main/java/org/jabref/logic/shared/DBMSType.java
@@ -13,10 +13,10 @@ public enum DBMSType {
private final String type;
private final String driverPath;
- private final String urlPattern;
+ private String urlPattern;
private final int defaultPort;
- private DBMSType(String type, String driverPath, String urlPattern, int defaultPort) {
+ DBMSType(String type, String driverPath, String urlPattern, int defaultPort) {
this.type = type;
this.driverPath = driverPath;
this.urlPattern = urlPattern;
diff --git a/src/main/java/org/jabref/logic/shared/DatabaseConnectionProperties.java b/src/main/java/org/jabref/logic/shared/DatabaseConnectionProperties.java
index 6c3d44313a9..72e2f546244 100644
--- a/src/main/java/org/jabref/logic/shared/DatabaseConnectionProperties.java
+++ b/src/main/java/org/jabref/logic/shared/DatabaseConnectionProperties.java
@@ -23,4 +23,8 @@ public interface DatabaseConnectionProperties {
boolean isAllowPublicKeyRetrieval();
String getServerTimezone();
+
+ String getJdbcUrl();
+
+ boolean isUseExpertMode();
}
diff --git a/src/main/java/org/jabref/logic/shared/prefs/SharedDatabasePreferences.java b/src/main/java/org/jabref/logic/shared/prefs/SharedDatabasePreferences.java
index 4b1a14fe1c9..360c9541730 100644
--- a/src/main/java/org/jabref/logic/shared/prefs/SharedDatabasePreferences.java
+++ b/src/main/java/org/jabref/logic/shared/prefs/SharedDatabasePreferences.java
@@ -31,6 +31,8 @@ public class SharedDatabasePreferences {
private static final String SHARED_DATABASE_USE_SSL = "sharedDatabaseUseSSL";
private static final String SHARED_DATABASE_KEYSTORE_FILE = "sharedDatabaseKeyStoreFile";
private static final String SHARED_DATABASE_SERVER_TIMEZONE = "sharedDatabaseServerTimezone";
+ private static final String SHARED_DATABASE_EXPERT_MODE = "sharedDatabaseExpertMode";
+ private static final String SHARED_DATABASE_JDBC_URL = "sharedDatabaseJdbcUrl";
// This {@link Preferences} is used only for things which should not appear in real JabRefPreferences due to security reasons.
private final Preferences internalPrefs;
@@ -143,6 +145,22 @@ public void clearPassword() {
internalPrefs.remove(SHARED_DATABASE_PASSWORD);
}
+ public void setExpertMode(boolean expertMode) {
+ internalPrefs.putBoolean(SHARED_DATABASE_EXPERT_MODE, expertMode);
+ }
+
+ public void setJdbcUrl(String jdbcUrl) {
+ internalPrefs.put(SHARED_DATABASE_JDBC_URL, jdbcUrl);
+ }
+
+ public boolean isUseExpertMode() {
+ return internalPrefs.getBoolean(SHARED_DATABASE_EXPERT_MODE, false);
+ }
+
+ public Optional getJdbcUrl() {
+ return getOptionalValue(SHARED_DATABASE_JDBC_URL);
+ }
+
public void clear() throws BackingStoreException {
internalPrefs.clear();
}
@@ -166,6 +184,8 @@ public void putAllDBMSConnectionProperties(DatabaseConnectionProperties properti
setUseSSL(properties.isUseSSL());
setKeystoreFile(properties.getKeyStore());
setServerTimezone(properties.getServerTimezone());
+ setExpertMode(properties.isUseExpertMode());
+ setJdbcUrl(properties.getJdbcUrl());
try {
setPassword(new Password(properties.getPassword().toCharArray(), properties.getUser()).encrypt());
diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties
index 07b38d07b25..13139f857dc 100644
--- a/src/main/resources/l10n/JabRef_en.properties
+++ b/src/main/resources/l10n/JabRef_en.properties
@@ -614,6 +614,9 @@ Open\ last\ edited\ libraries\ on\ startup=Open last edited libraries on startup
Connect\ to\ shared\ database=Connect to shared database
+Use\ Expert\ mode=Use Expert mode
+Custom\ JDBC\ Url\:=Custom JDBC Url:
+
Open\ terminal\ here=Open terminal here
Open\ URL\ or\ DOI=Open URL or DOI