comparison artifact-database/src/main/java/de/intevation/artifactdatabase/SQL.java @ 17:5a6b6a3debc7

Integrated logging into artifact database. artifacts/trunk@33 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 08 Sep 2009 06:29:52 +0000
parents 0d16d1bb2df0
children 4ae4dc99127d
comparison
equal deleted inserted replaced
16:635310c6a20e 17:5a6b6a3debc7
3 import java.util.Properties; 3 import java.util.Properties;
4 4
5 import java.io.IOException; 5 import java.io.IOException;
6 import java.io.InputStream; 6 import java.io.InputStream;
7 7
8 import org.apache.log4j.Logger;
9
8 /** 10 /**
9 * @author Sascha L. Teichmann 11 * @author Sascha L. Teichmann
10 */ 12 */
11 public final class SQL 13 public final class SQL
12 { 14 {
15 private static Logger logger = Logger.getLogger(SQL.class);
16
13 private SQL() { 17 private SQL() {
14 } 18 }
15 19
16 private static Properties statements; 20 private static Properties statements;
17 21
33 String res = "/sql/" + driver.replace('.', '-').toLowerCase() 37 String res = "/sql/" + driver.replace('.', '-').toLowerCase()
34 + ".properties"; 38 + ".properties";
35 in = SQL.class.getResourceAsStream(res); 39 in = SQL.class.getResourceAsStream(res);
36 40
37 if (in == null) { 41 if (in == null) {
38 System.err.println("WARNING: no SQL file for driver '" 42 logger.warn("No SQL file for driver '" + driver + "' found.");
39 + driver + "' found.");
40 res = "/sql/" + DBConnection.DEFAULT_DRIVER.replace('.', '-').toLowerCase() 43 res = "/sql/" + DBConnection.DEFAULT_DRIVER.replace('.', '-').toLowerCase()
41 + ".properties"; 44 + ".properties";
42 if ((in = SQL.class.getResourceAsStream(res)) == null) { 45 if ((in = SQL.class.getResourceAsStream(res)) == null) {
43 System.err.println("ERROR: no SQL file found"); 46 logger.error("No SQL file found");
44 } 47 }
45 } 48 }
46 49
47 properties.load(in); 50 properties.load(in);
48 } 51 }
49 catch (IOException ioe) { 52 catch (IOException ioe) {
50 ioe.printStackTrace(System.err); 53 logger.error(ioe.getLocalizedMessage(), ioe);
51 } 54 }
52 finally { 55 finally {
53 if (in != null) { 56 if (in != null) {
54 try { in.close(); } catch (IOException ioe) {} 57 try { in.close(); } catch (IOException ioe) {}
55 } 58 }

http://dive4elements.wald.intevation.org