Mercurial > dive4elements > framework
view artifact-database/src/main/java/de/intevation/artifactdatabase/SQL.java @ 66:89e3de0ee05f
Implemented some methods to get access to ArtifactFactories which are stored in the ArtifactDatabase.
artifacts/trunk@546 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 15 Jan 2010 17:39:32 +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: