Mercurial > dive4elements > framework
view artifact-database/src/main/java/de/intevation/artifactdatabase/SQL.java @ 68:541814404822
Added interfaces for XML processing services. TODO: Implement them!
artifacts/trunk@593 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 22 Jan 2010 09:48:18 +0000 |
parents | 4ae4dc99127d |
children | 8447467cef86 |
line wrap: on
line source
package de.intevation.artifactdatabase; import java.util.Properties; import java.io.IOException; import java.io.InputStream; import org.apache.log4j.Logger; /** * @author Sascha L. Teichmann */ public final class SQL { private static Logger logger = Logger.getLogger(SQL.class); private SQL() { } private static Properties statements; public static final synchronized Properties getStatements() { if (statements == null) { statements = loadStatements(); } return statements; } private static final Properties loadStatements() { String driver = Config.getStringXPath( DBConnection.DB_DRIVER, DBConnection.DEFAULT_DRIVER); Properties properties = new Properties(); InputStream in = null; try { String res = "/sql/" + driver.replace('.', '-').toLowerCase() + ".properties"; in = SQL.class.getResourceAsStream(res); if (in == null) { logger.warn("No SQL file for driver '" + driver + "' found."); res = "/sql/" + DBConnection.DEFAULT_DRIVER.replace('.', '-').toLowerCase() + ".properties"; if ((in = SQL.class.getResourceAsStream(res)) == null) { logger.error("No SQL file found"); } } properties.load(in); } catch (IOException ioe) { logger.error(ioe.getLocalizedMessage(), ioe); } finally { if (in != null) { try { in.close(); } catch (IOException ioe) {} } } return properties; } public static final String get(String key) { return getStatements().getProperty(key); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: