comparison artifact-database/src/main/java/de/intevation/artifactdatabase/DBConnection.java @ 38:93edc04f3a10

Added postgresql support. artifacts/trunk@104 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 18 Sep 2009 09:34:14 +0000
parents 1259d192e3c3
children 0f48188a6e02
comparison
equal deleted inserted replaced
37:3f03aee55c2f 38:93edc04f3a10
6 6
7 import org.apache.commons.dbcp.BasicDataSource; 7 import org.apache.commons.dbcp.BasicDataSource;
8 8
9 import java.io.File; 9 import java.io.File;
10 10
11 import org.apache.log4j.Logger;
12
11 /** 13 /**
12 * @author Sascha L. Teichmann 14 * @author Sascha L. Teichmann
13 */ 15 */
14 public class DBConnection 16 public class DBConnection
15 { 17 {
18 private static Logger logger = Logger.getLogger(DBConnection.class);
19
16 public static final String DB_DRIVER = 20 public static final String DB_DRIVER =
17 "/artifacts-database/database/driver/text()"; 21 "/artifact-database/database/driver/text()";
18 public static final String DB_URL = 22 public static final String DB_URL =
19 "/artifacts-database/database/url/text()"; 23 "/artifact-database/database/url/text()";
20 public static final String DB_USER = 24 public static final String DB_USER =
21 "/artifacts-database/database/user/text()"; 25 "/artifact-database/database/user/text()";
22 public static final String DB_PASSWORD = 26 public static final String DB_PASSWORD =
23 "/artifacts-database/database/password/text()"; 27 "/artifact-database/database/password/text()";
24 28
25 public static final String DEFAULT_DRIVER = 29 public static final String DEFAULT_DRIVER =
26 "org.h2.Driver"; 30 "org.h2.Driver";
27 31
28 public static final String DEFAULT_DATABASE_FILE = 32 public static final String DEFAULT_DATABASE_FILE =
73 DB_USER, DEFAULT_USER); 77 DB_USER, DEFAULT_USER);
74 78
75 String password = Config.getStringXPath( 79 String password = Config.getStringXPath(
76 DB_PASSWORD, DEFAULT_PASSWORD); 80 DB_PASSWORD, DEFAULT_PASSWORD);
77 81
82 logger.info("database driver: " + driver);
83 logger.info("database url: " + url);
84
78 dataSource.setDriverClassName(driver); 85 dataSource.setDriverClassName(driver);
79 dataSource.setUsername(user); 86 dataSource.setUsername(user);
80 dataSource.setPassword(password); 87 dataSource.setPassword(password);
81 dataSource.setUrl(url); 88 dataSource.setUrl(url);
82 addShutdownHook(); 89 addShutdownHook();

http://dive4elements.wald.intevation.org