From f802480190d566206ae94252549b41a2a16bc21e Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 19 Aug 2015 17:24:54 +0200 Subject: [PATCH] =?utf8?q?Added=20null=20check=20+=20fixed=20path=20for=20?= =?utf8?q?file-based=20database=20backends=20Signed-off-by:Roland=20H?= =?utf8?q?=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/org/mxchange/jcore/BaseFrameworkSystem.java | 2 +- .../jcore/database/backend/BaseDatabaseBackend.java | 8 +++++++- .../exceptions/UnsupportedDatabaseDriverException.java | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/org/mxchange/jcore/BaseFrameworkSystem.java b/src/org/mxchange/jcore/BaseFrameworkSystem.java index 4b6d025..9e74ec3 100644 --- a/src/org/mxchange/jcore/BaseFrameworkSystem.java +++ b/src/org/mxchange/jcore/BaseFrameworkSystem.java @@ -364,7 +364,7 @@ public class BaseFrameworkSystem implements FrameworkInterface { // Init default values: // Default database backend BaseFrameworkSystem.properties.put("org.mxchange.database.backend.class", "org.mxchange.jcore.database.backend.base64.Base64CsvDatabaseBackend"); //NOI18N - BaseFrameworkSystem.properties.put("database.backend.storagepath", "data/"); //NOI18N + BaseFrameworkSystem.properties.put("org.mxchange.database.backend.storagepath", "data/"); //NOI18N // For MySQL backend BaseFrameworkSystem.properties.put("org.mxchange.database.mysql.host", "localhost"); //NOI18N diff --git a/src/org/mxchange/jcore/database/backend/BaseDatabaseBackend.java b/src/org/mxchange/jcore/database/backend/BaseDatabaseBackend.java index 39a773e..d63fafc 100644 --- a/src/org/mxchange/jcore/database/backend/BaseDatabaseBackend.java +++ b/src/org/mxchange/jcore/database/backend/BaseDatabaseBackend.java @@ -46,7 +46,13 @@ public class BaseDatabaseBackend extends BaseFrameworkSystem { // Trace message this.getLogger().trace(MessageFormat.format("driverName={0} - CALLED!", driverName)); //NOI18N - // Try to find the driver in driver list + // driverName shall not be null + if (driverName == null) { + // Is null + throw new NullPointerException("driverName is null"); + } + + // Get all registered/installed drivers Enumeration drivers = DriverManager.getDrivers(); // Default is not found diff --git a/src/org/mxchange/jcore/exceptions/UnsupportedDatabaseDriverException.java b/src/org/mxchange/jcore/exceptions/UnsupportedDatabaseDriverException.java index 3cc925d..c97a26a 100644 --- a/src/org/mxchange/jcore/exceptions/UnsupportedDatabaseDriverException.java +++ b/src/org/mxchange/jcore/exceptions/UnsupportedDatabaseDriverException.java @@ -31,7 +31,7 @@ public class UnsupportedDatabaseDriverException extends Exception { */ public UnsupportedDatabaseDriverException (final String driverName) { // Call super method - super(MessageFormat.format("Database driver {0} is not found.", driverName)); + super(MessageFormat.format("Database driver {0} is not found.", driverName)); //NOI18N } } -- 2.39.5