comparison 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
comparison
equal deleted inserted replaced
18:63a8aa276693 19:1259d192e3c3
3 import javax.sql.DataSource; 3 import javax.sql.DataSource;
4 4
5 import java.sql.SQLException; 5 import java.sql.SQLException;
6 6
7 import org.apache.commons.dbcp.BasicDataSource; 7 import org.apache.commons.dbcp.BasicDataSource;
8
9 import java.io.File;
8 10
9 /** 11 /**
10 * @author Sascha L. Teichmann 12 * @author Sascha L. Teichmann
11 */ 13 */
12 public class DBConnection 14 public class DBConnection
21 "/artifacts-database/database/password/text()"; 23 "/artifacts-database/database/password/text()";
22 24
23 public static final String DEFAULT_DRIVER = 25 public static final String DEFAULT_DRIVER =
24 "org.h2.Driver"; 26 "org.h2.Driver";
25 27
26 public static final String DEFAULT_URL = 28 public static final String DEFAULT_DATABASE_FILE =
27 "jdbc:h2:artifacts.db"; 29 "artifacts.db";
30
31 public static final String DEFAULT_URL = getDefaultURL();
28 32
29 public static final String DEFAULT_USER = ""; 33 public static final String DEFAULT_USER = "";
30 public static final String DEFAULT_PASSWORD = ""; 34 public static final String DEFAULT_PASSWORD = "";
31 35
32 private DBConnection() { 36 private DBConnection() {
37 }
38
39 public static final String getDefaultURL() {
40 File configDir = Config.getConfigDirectory();
41 File databaseFile = new File(configDir, DEFAULT_DATABASE_FILE);
42 return "jdbc:h2:" + databaseFile;
33 } 43 }
34 44
35 private static BasicDataSource dataSource; 45 private static BasicDataSource dataSource;
36 46
37 private static final void addShutdownHook() { 47 private static final void addShutdownHook() {

http://dive4elements.wald.intevation.org