Mercurial > dive4elements > framework
view artifact-database/src/main/java/de/intevation/artifactdatabase/SQL.java @ 33:251e8904d6c2
Make the Interfaces Serializable to make them usable in the Artifactdatabase.
Bug Fixed in SQL-Statement
artifacts/trunk@81 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Mon, 14 Sep 2009 13:36:35 +0000 |
parents | 5a6b6a3debc7 |
children | 4ae4dc99127d |
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: