Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/db/SQL.java @ 307:d96bcb40dbf9
Make artifact server bootable again.
artifacts/trunk@2425 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 31 Jul 2011 15:18:57 +0000 |
parents | f33401ea2a6c |
children | c40729bfe06d |
comparison
equal
deleted
inserted
replaced
306:9dbeb88006e9 | 307:d96bcb40dbf9 |
---|---|
23 public SQL(Class clazz, String driver) { | 23 public SQL(Class clazz, String driver) { |
24 this(clazz, "/sql", driver); | 24 this(clazz, "/sql", driver); |
25 } | 25 } |
26 | 26 |
27 public SQL(Class clazz, String resourcePath, String driver) { | 27 public SQL(Class clazz, String resourcePath, String driver) { |
28 statements = loadStatements(clazz, resourcePath, driver); | |
28 } | 29 } |
29 | 30 |
30 public static final String driverToProperties(String driver) { | 31 public static final String driverToProperties(String driver) { |
31 return driver.replace('.', '-').toLowerCase() + ".properties"; | 32 return driver.replace('.', '-').toLowerCase() + ".properties"; |
32 } | 33 } |
48 protected Properties loadStatements( | 49 protected Properties loadStatements( |
49 Class clazz, | 50 Class clazz, |
50 String resourcePath, | 51 String resourcePath, |
51 String driver | 52 String driver |
52 ) { | 53 ) { |
54 logger.debug("loadStatements"); | |
55 | |
53 Properties properties = new Properties(); | 56 Properties properties = new Properties(); |
54 | 57 |
55 String resDriver = driverToProperties(driver); | 58 String resDriver = driverToProperties(driver); |
56 | 59 |
57 InputStream in = null; | 60 InputStream in = null; |
69 if (in == null) { | 72 if (in == null) { |
70 logger.error("No SQL file for driver '" + | 73 logger.error("No SQL file for driver '" + |
71 DBConnection.DEFAULT_DRIVER + "' found."); | 74 DBConnection.DEFAULT_DRIVER + "' found."); |
72 } | 75 } |
73 } | 76 } |
77 else { | |
78 if (logger.isDebugEnabled()) { | |
79 logger.debug("found resource: " + res); | |
80 } | |
81 } | |
74 | 82 |
75 if (in != null) { | 83 if (in != null) { |
76 properties.load(in); | 84 properties.load(in); |
77 } | 85 } |
78 } | 86 } |
82 | 90 |
83 return properties; | 91 return properties; |
84 } | 92 } |
85 | 93 |
86 public String get(String key) { | 94 public String get(String key) { |
87 return statements.getProperty(key); | 95 boolean debug = logger.isDebugEnabled(); |
96 if (debug) { | |
97 logger.debug("looking for SQL " + key); | |
98 logger.debug("statements != null: " + (statements != null)); | |
99 } | |
100 | |
101 String sql = statements.getProperty(key); | |
102 | |
103 if (sql == null) { | |
104 logger.error("cannot find SQL for key '" + key + "'"); | |
105 } | |
106 | |
107 if (debug) { | |
108 logger.debug("-> '" + sql + "'"); | |
109 } | |
110 | |
111 return sql; | |
88 } | 112 } |
89 } | 113 } |
90 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 114 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |