You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2013/12/05 14:45:03 UTC
git commit: Added proper log message on missing database driver in
KiWi.
Updated Branches:
refs/heads/develop a71ac3669 -> f6db7d9cc
Added proper log message on missing database driver in KiWi.
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/f6db7d9c
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/f6db7d9c
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/f6db7d9c
Branch: refs/heads/develop
Commit: f6db7d9cca28d7da1c03d7bb27d19981069f5c67
Parents: a71ac36
Author: Jakob Frank <ja...@apache.org>
Authored: Thu Dec 5 14:44:04 2013 +0100
Committer: Jakob Frank <ja...@apache.org>
Committed: Thu Dec 5 14:44:04 2013 +0100
----------------------------------------------------------------------
.../marmotta/kiwi/persistence/KiWiDialect.java | 18 ++++++++-------
.../marmotta/kiwi/persistence/h2/H2Dialect.java | 2 +-
.../kiwi/persistence/mysql/MySQLDialect.java | 2 +-
.../persistence/pgsql/PostgreSQLDialect.java | 3 +--
.../backend/kiwi/KiWiStoreProvider.java | 23 +++++++++++++-------
5 files changed, 28 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/f6db7d9c/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiDialect.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiDialect.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiDialect.java
index e2dbd66..95d5c47 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiDialect.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiDialect.java
@@ -17,13 +17,6 @@
*/
package org.apache.marmotta.kiwi.persistence;
-import com.google.common.collect.ImmutableSet;
-import org.apache.commons.io.IOUtils;
-import org.openrdf.model.URI;
-import org.openrdf.model.vocabulary.FN;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.net.URL;
import java.util.Collections;
import java.util.Enumeration;
@@ -31,6 +24,15 @@ import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
+import org.apache.commons.io.IOUtils;
+import org.apache.marmotta.kiwi.exception.DriverNotFoundException;
+import org.openrdf.model.URI;
+import org.openrdf.model.vocabulary.FN;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableSet;
+
/**
* A dialect provides the SQL statements necessary to access the different types of database systems. Each
* method should return a PreparedStatement that can be executed on the respective JDBC connection
@@ -47,7 +49,7 @@ public abstract class KiWiDialect {
private Properties statements;
- protected KiWiDialect() {
+ protected KiWiDialect() throws DriverNotFoundException {
statements = new Properties();
// load all statements.properties files that can be located in the same package (from different modules in different jar files)
http://git-wip-us.apache.org/repos/asf/marmotta/blob/f6db7d9c/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/h2/H2Dialect.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/h2/H2Dialect.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/h2/H2Dialect.java
index 81111df..a000390 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/h2/H2Dialect.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/h2/H2Dialect.java
@@ -32,7 +32,7 @@ import org.openrdf.model.vocabulary.XMLSchema;
*/
public class H2Dialect extends KiWiDialect {
- public H2Dialect() {
+ public H2Dialect() throws DriverNotFoundException {
try {
Class.forName(getDriverClass());
} catch (ClassNotFoundException e) {
http://git-wip-us.apache.org/repos/asf/marmotta/blob/f6db7d9c/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/mysql/MySQLDialect.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/mysql/MySQLDialect.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/mysql/MySQLDialect.java
index 5317003..6d0ef10 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/mysql/MySQLDialect.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/mysql/MySQLDialect.java
@@ -44,7 +44,7 @@ import org.openrdf.model.vocabulary.XMLSchema;
public class MySQLDialect extends KiWiDialect {
- public MySQLDialect() {
+ public MySQLDialect() throws DriverNotFoundException {
try {
Class.forName(getDriverClass());
} catch (ClassNotFoundException e) {
http://git-wip-us.apache.org/repos/asf/marmotta/blob/f6db7d9c/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/pgsql/PostgreSQLDialect.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/pgsql/PostgreSQLDialect.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/pgsql/PostgreSQLDialect.java
index c438039..854fc99 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/pgsql/PostgreSQLDialect.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/pgsql/PostgreSQLDialect.java
@@ -33,8 +33,7 @@ import org.openrdf.model.vocabulary.XMLSchema;
*/
public class PostgreSQLDialect extends KiWiDialect {
- public PostgreSQLDialect() {
- super();
+ public PostgreSQLDialect() throws DriverNotFoundException {
try {
Class.forName(getDriverClass());
} catch (ClassNotFoundException e) {
http://git-wip-us.apache.org/repos/asf/marmotta/blob/f6db7d9c/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiStoreProvider.java
----------------------------------------------------------------------
diff --git a/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiStoreProvider.java b/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiStoreProvider.java
index 00bbbd8..3718afe 100644
--- a/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiStoreProvider.java
+++ b/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiStoreProvider.java
@@ -19,6 +19,7 @@ package org.apache.marmotta.platform.backend.kiwi;
import com.google.common.collect.ImmutableList;
import org.apache.marmotta.kiwi.config.KiWiConfiguration;
+import org.apache.marmotta.kiwi.exception.DriverNotFoundException;
import org.apache.marmotta.kiwi.persistence.KiWiDialect;
import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
@@ -85,14 +86,20 @@ public class KiWiStoreProvider implements StoreProvider {
String database = configurationService.getStringConfiguration("database.type");
KiWiDialect dialect;
- if("h2".equalsIgnoreCase(database)) {
- dialect = new H2Dialect();
- } else if("mysql".equalsIgnoreCase(database)) {
- dialect = new MySQLDialect();
- } else if("postgres".equalsIgnoreCase(database)) {
- dialect = new PostgreSQLDialect();
- } else
- throw new IllegalStateException("database type "+database+" currently not supported!");
+ try {
+ if("h2".equalsIgnoreCase(database)) {
+ dialect = new H2Dialect();
+ } else if("mysql".equalsIgnoreCase(database)) {
+ dialect = new MySQLDialect();
+ } else if("postgres".equalsIgnoreCase(database)) {
+ dialect = new PostgreSQLDialect();
+ } else
+ throw new IllegalStateException("database type "+database+" currently not supported!");
+ } catch (DriverNotFoundException dnf) {
+ log.error("{}, can't build KiwiStore.", dnf.getMessage());
+ throw dnf;
+ }
+
String jdbcUrl = configurationService.getStringConfiguration("database.url");
String dbUser = configurationService.getStringConfiguration("database.user");
String dbPass = configurationService.getStringConfiguration("database.password");