Mercurial > dive4elements > river
annotate flys-aft/src/main/java/de/intevation/db/Statements.java @ 4071:0f5cc88a0f74
Added configuration file
flys-aft/trunk@3398 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 13 Dec 2011 10:11:23 +0000 |
parents | a4e79e8e0aa0 |
children | 2c70fae83d0c |
rev | line source |
---|---|
4068
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.db; |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import java.util.Properties; |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import java.io.IOException; |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 import java.io.InputStream; |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 import org.apache.log4j.Logger; |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 |
4069
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
10 import java.util.List; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
11 import java.util.ArrayList; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
12 import java.util.Map; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
13 import java.util.HashMap; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
14 import java.util.Enumeration; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
15 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
16 import java.sql.Connection; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
17 import java.sql.SQLException; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
18 import java.sql.PreparedStatement; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
19 import java.sql.Timestamp; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
20 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
21 import java.util.regex.Matcher; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
22 import java.util.regex.Pattern; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
23 |
4068
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 public class Statements |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 { |
4069
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
26 public static final Pattern VAR = Pattern.compile(":([a-zA-Z0-9_]+)"); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
27 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
28 public static class SymbolicStatement { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
29 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
30 protected String statement; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
31 protected String compiled; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
32 protected Map<String, List<Integer>> positions; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
33 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
34 public class Instance { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
35 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
36 /** TODO: Support more types. */ |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
37 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
38 protected PreparedStatement stmnt; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
39 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
40 public Instance(Connection connection) throws SQLException { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
41 stmnt = connection.prepareStatement(compiled); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
42 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
43 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
44 public void close() { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
45 try { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
46 stmnt.close(); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
47 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
48 catch (SQLException sqle) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
49 log.error("cannot close statement", sqle); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
50 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
51 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
52 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
53 public void setInt(String key, int value) |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
54 throws SQLException |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
55 { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
56 List<Integer> pos = positions.get(key.toLowerCase()); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
57 if (pos != null) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
58 for (Integer p: pos) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
59 stmnt.setInt(p, value); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
60 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
61 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
62 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
63 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
64 public void setString(String key, String value) |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
65 throws SQLException |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
66 { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
67 List<Integer> pos = positions.get(key.toLowerCase()); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
68 if (pos != null) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
69 for (Integer p: pos) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
70 stmnt.setString(p, value); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
71 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
72 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
73 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
74 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
75 public void setObject(String key, Object value) |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
76 throws SQLException |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
77 { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
78 List<Integer> pos = positions.get(key.toLowerCase()); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
79 if (pos != null) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
80 for (Integer p: pos) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
81 stmnt.setObject(p, value); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
82 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
83 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
84 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
85 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
86 public void setTimestamp(String key, Timestamp value) |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
87 throws SQLException |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
88 { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
89 List<Integer> pos = positions.get(key.toLowerCase()); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
90 if (pos != null) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
91 for (Integer p: pos) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
92 stmnt.setTimestamp(p, value); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
93 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
94 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
95 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
96 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
97 public void setDouble(String key, int value) |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
98 throws SQLException |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
99 { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
100 List<Integer> pos = positions.get(key.toLowerCase()); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
101 if (pos != null) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
102 for (Integer p: pos) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
103 stmnt.setDouble(p, value); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
104 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
105 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
106 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
107 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
108 public void setNull(String key, int sqlType) |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
109 throws SQLException |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
110 { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
111 List<Integer> pos = positions.get(key.toLowerCase()); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
112 if (pos != null) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
113 for (Integer p: pos) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
114 stmnt.setNull(p, sqlType); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
115 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
116 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
117 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
118 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
119 public void set(Map<String, Object> map) throws SQLException { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
120 for (Map.Entry<String, Object> entry: map.entrySet()) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
121 setObject(entry.getKey(), entry.getValue()); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
122 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
123 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
124 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
125 } // class Instance |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
126 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
127 public SymbolicStatement(String statement) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
128 this.statement = statement; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
129 compile(); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
130 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
131 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
132 public String getStatement() { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
133 return statement; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
134 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
135 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
136 protected void compile() { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
137 positions = new HashMap<String, List<Integer>>(); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
138 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
139 StringBuffer sb = new StringBuffer(); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
140 Matcher m = VAR.matcher(statement); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
141 int index = 1; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
142 while (m.find()) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
143 String key = m.group(1).toLowerCase(); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
144 List<Integer> list = positions.get(key); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
145 if (list == null) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
146 list = new ArrayList<Integer>(); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
147 positions.put(key, list); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
148 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
149 list.add(index++); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
150 m.appendReplacement(sb, "?"); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
151 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
152 m.appendTail(sb); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
153 compiled = sb.toString(); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
154 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
155 } // class SymbolicStatement |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
156 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
157 |
4068
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
158 private static Logger log = Logger.getLogger(Statements.class); |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
159 |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
160 public static final String RESOURCE_PATH = "/sql/"; |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
161 public static final String COMMON_PROPERTIES = "-common.properties"; |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
162 |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
163 protected String type; |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
164 protected String driver; |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
165 |
4069
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
166 protected Map<String, SymbolicStatement> statements; |
4068
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
167 |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
168 public Statements(String type, String driver) { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
169 this.type = type; |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
170 this.driver = driver; |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
171 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
172 |
4069
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
173 public SymbolicStatement getStatement(String key) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
174 if (statements == null) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
175 statements = loadStatements(); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
176 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
177 return statements.get(key); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
178 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
179 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
180 protected Map<String, SymbolicStatement> loadStatements() { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
181 Map<String, SymbolicStatement> statements = |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
182 new HashMap<String, SymbolicStatement>(); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
183 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
184 Properties properties = loadProperties(); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
185 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
186 for (Enumeration e = properties.propertyNames(); e.hasMoreElements();) { |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
187 String key = (String)e.nextElement(); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
188 String value = properties.getProperty(key); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
189 SymbolicStatement symbolic = new SymbolicStatement(value); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
190 statements.put(key, symbolic); |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
191 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
192 |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
193 return statements; |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
194 } |
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
195 |
4068
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
196 protected String driverToProperties() { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
197 return |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
198 type + "-" + |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
199 driver.replace('.', '-').toLowerCase() + ".properties"; |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
200 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
201 |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
202 protected Properties loadCommon() { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
203 Properties common = new Properties(); |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
204 |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
205 String path = RESOURCE_PATH + type + COMMON_PROPERTIES; |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
206 |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
207 InputStream in = Statements.class.getResourceAsStream(path); |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
208 |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
209 if (in != null) { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
210 try { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
211 common.load(in); |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
212 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
213 catch (IOException ioe) { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
214 log.error("cannot load defaults: " + path, ioe); |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
215 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
216 finally { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
217 try { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
218 in.close(); |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
219 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
220 catch (IOException ioe) { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
221 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
222 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
223 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
224 else { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
225 log.warn("cannot find: " + path); |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
226 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
227 |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
228 return common; |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
229 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
230 |
4069
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
231 protected Properties loadProperties() { |
4068
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
232 |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
233 Properties common = loadCommon(); |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
234 |
4069
a4e79e8e0aa0
Added support for symbolic SQL statements.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4068
diff
changeset
|
235 Properties properties = new Properties(common); |
4068
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
236 |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
237 String path = RESOURCE_PATH + driverToProperties(); |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
238 |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
239 InputStream in = Statements.class.getResourceAsStream(path); |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
240 |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
241 if (in != null) { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
242 try { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
243 properties.load(in); |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
244 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
245 catch (IOException ioe) { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
246 log.error("cannot load statements: " + path, ioe); |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
247 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
248 finally { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
249 try { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
250 in.close(); |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
251 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
252 catch (IOException ioe) { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
253 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
254 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
255 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
256 else { |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
257 log.warn("cannot find: " + path); |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
258 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
259 |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
260 return properties; |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
261 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
262 } |
21e49e0a2307
Add infrastructure to load SQL statements for databases.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
263 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |