diff artifact-database/src/main/java/de/intevation/artifactdatabase/DBConnection.java @ 19:1259d192e3c3

* New configuration based on config directory * Artifact database launches REST web server at startup. artifacts/trunk@43 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 09 Sep 2009 07:55:44 +0000
parents 3f01e317f615
children 93edc04f3a10
line wrap: on
line diff
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DBConnection.java	Tue Sep 08 07:51:34 2009 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DBConnection.java	Wed Sep 09 07:55:44 2009 +0000
@@ -6,6 +6,8 @@
 
 import org.apache.commons.dbcp.BasicDataSource;
 
+import java.io.File;
+
 /**
  *  @author Sascha L. Teichmann
  */
@@ -23,8 +25,10 @@
     public static final String DEFAULT_DRIVER =
         "org.h2.Driver";
 
-    public static final String DEFAULT_URL =
-        "jdbc:h2:artifacts.db";
+    public static final String DEFAULT_DATABASE_FILE =
+        "artifacts.db";
+
+    public static final String DEFAULT_URL = getDefaultURL();
 
     public static final String DEFAULT_USER     = "";
     public static final String DEFAULT_PASSWORD = "";
@@ -32,6 +36,12 @@
     private DBConnection() {
     }
 
+    public static final String getDefaultURL() {
+        File configDir = Config.getConfigDirectory();
+        File databaseFile = new File(configDir, DEFAULT_DATABASE_FILE);
+        return "jdbc:h2:" + databaseFile;
+    }
+
     private static BasicDataSource dataSource;
 
     private static final void addShutdownHook() {

http://dive4elements.wald.intevation.org