Mercurial > dive4elements > framework
view artifact-database/src/main/java/de/intevation/artifactdatabase/SQL.java @ 15:9ad6ec2d09c3
Implemented restoring artifacts from database.
artifacts/trunk@30 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 07 Sep 2009 10:06:23 +0000 |
parents | 0d16d1bb2df0 |
children | 5a6b6a3debc7 |
line wrap: on
line source
package de.intevation.artifactdatabase; import java.util.Properties; import java.io.IOException; import java.io.InputStream; /** * @author Sascha L. Teichmann */ public final class SQL { 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) { System.err.println("WARNING: no SQL file for driver '" + driver + "' found."); res = "/sql/" + DBConnection.DEFAULT_DRIVER.replace('.', '-').toLowerCase() + ".properties"; if ((in = SQL.class.getResourceAsStream(res)) == null) { System.err.println("ERROR: no SQL file found"); } } properties.load(in); } catch (IOException ioe) { ioe.printStackTrace(System.err); } 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: