diff --git a/src/main/java/org/jabref/logic/shared/DBMSConnection.java b/src/main/java/org/jabref/logic/shared/DBMSConnection.java index 89952950add..0ab33ca8eef 100644 --- a/src/main/java/org/jabref/logic/shared/DBMSConnection.java +++ b/src/main/java/org/jabref/logic/shared/DBMSConnection.java @@ -1,19 +1,18 @@ package org.jabref.logic.shared; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.util.HashSet; -import java.util.Set; - import org.jabref.logic.l10n.Localization; import org.jabref.logic.shared.exception.InvalidDBMSConnectionPropertiesException; import org.jabref.model.database.shared.DBMSType; import org.jabref.model.database.shared.DatabaseConnection; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.HashSet; +import java.util.Set; + public class DBMSConnection implements DatabaseConnection { private static final Logger LOGGER = LoggerFactory.getLogger(DBMSConnection.class); @@ -38,9 +37,12 @@ public DBMSConnection(DBMSConnectionProperties connectionProperties) throws SQLE } 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()); + String message = e.getMessage(); + int endIndex = message.indexOf(".") != -1 ? message.indexOf(".") : message.length(); + String errorMessagee = e.getSQLState().equals("01S00") ? message.substring(0, endIndex) : message; + LOGGER.error("Could not connect to database: " + message + " - Error code: " + e.getErrorCode()); - throw e; + throw new SQLException(errorMessagee, e); } }