diff 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
line wrap: on
line diff
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/db/SQL.java	Thu Jul 28 14:08:25 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/db/SQL.java	Sun Jul 31 15:18:57 2011 +0000
@@ -25,6 +25,7 @@
     }
 
     public SQL(Class clazz, String resourcePath, String driver) {
+        statements = loadStatements(clazz, resourcePath, driver);
     }
 
     public static final String driverToProperties(String driver) {
@@ -50,6 +51,8 @@
         String resourcePath,
         String driver
     ) { 
+        logger.debug("loadStatements");
+
         Properties properties = new Properties();
 
         String resDriver = driverToProperties(driver);
@@ -71,6 +74,11 @@
                         DBConnection.DEFAULT_DRIVER + "' found.");
                 }
             }
+            else {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("found resource: " + res);
+                }
+            }
 
             if (in != null) {
                 properties.load(in);
@@ -84,7 +92,23 @@
     }
 
     public String get(String key) {
-        return statements.getProperty(key);
+        boolean debug = logger.isDebugEnabled();
+        if (debug) {
+            logger.debug("looking for SQL " + key);
+            logger.debug("statements != null: " + (statements != null));
+        }
+
+        String sql = statements.getProperty(key);
+
+        if (sql == null) {
+            logger.error("cannot find SQL for key '" + key + "'");
+        }
+
+        if (debug) {
+            logger.debug("-> '" + sql + "'"); 
+        }
+
+        return sql;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org