Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/backend/SedDBCredentials.java @ 5193:fb9dcc68b9c2
Possible fix for flys/1202. Initial SQL statements can now be issued at connection creation.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 07 Mar 2013 17:39:25 +0100 |
parents | 76c75c8b9ee0 |
children | 92c8f8d1a3ba |
comparison
equal
deleted
inserted
replaced
5192:1b6d4edeeb4c | 5193:fb9dcc68b9c2 |
---|---|
71 "/artifact-database/seddb-database/driver/text()"; | 71 "/artifact-database/seddb-database/driver/text()"; |
72 | 72 |
73 public static final String XPATH_URL = | 73 public static final String XPATH_URL = |
74 "/artifact-database/seddb-database/url/text()"; | 74 "/artifact-database/seddb-database/url/text()"; |
75 | 75 |
76 public static final String XPATH_CONNECTION_INIT_SQLS = | |
77 "/artifact-database/seddb-database/connection-init-sqls/text()"; | |
78 | |
76 public static final String DEFAULT_USER = | 79 public static final String DEFAULT_USER = |
77 System.getProperty("flys.seddb.user", "seddb"); | 80 System.getProperty("flys.seddb.user", "seddb"); |
78 | 81 |
79 public static final String DEFAULT_PASSWORD = | 82 public static final String DEFAULT_PASSWORD = |
80 System.getProperty("flys.seddb.password", "seddb"); | 83 System.getProperty("flys.seddb.password", "seddb"); |
91 | 94 |
92 public static final String DEFAULT_URL = | 95 public static final String DEFAULT_URL = |
93 System.getProperty( | 96 System.getProperty( |
94 "flys.seddb.url", | 97 "flys.seddb.url", |
95 "jdbc:postgresql://localhost:5432/seddb"); | 98 "jdbc:postgresql://localhost:5432/seddb"); |
99 | |
100 public static final String DEFAULT_CONNECTION_INIT_SQLS = | |
101 System.getProperty( | |
102 "flys.seddb.connection.init.sqls"); | |
96 | 103 |
97 public static final Class [] CLASSES = { | 104 public static final Class [] CLASSES = { |
98 BezugspegelgewId.class, | 105 BezugspegelgewId.class, |
99 Bezugspegelgew.class, | 106 Bezugspegelgew.class, |
100 Bezugspegel.class, | 107 Bezugspegel.class, |
157 public SedDBCredentials( | 164 public SedDBCredentials( |
158 String user, | 165 String user, |
159 String password, | 166 String password, |
160 String dialect, | 167 String dialect, |
161 String driver, | 168 String driver, |
169 String connectionInitSqls, | |
162 String url | 170 String url |
163 ) { | 171 ) { |
164 super(user, password, dialect, driver, url, CLASSES); | 172 super(user, password, dialect, driver, url, connectionInitSqls, CLASSES); |
165 } | 173 } |
166 | 174 |
167 public static synchronized Credentials getInstance() { | 175 public static synchronized Credentials getInstance() { |
168 if (instance == null) { | 176 if (instance == null) { |
169 String user = | 177 String user = |
174 Config.getStringXPath(XPATH_DIALECT, DEFAULT_DIALECT); | 182 Config.getStringXPath(XPATH_DIALECT, DEFAULT_DIALECT); |
175 String driver = | 183 String driver = |
176 Config.getStringXPath(XPATH_DRIVER, DEFAULT_DRIVER); | 184 Config.getStringXPath(XPATH_DRIVER, DEFAULT_DRIVER); |
177 String url = | 185 String url = |
178 Config.getStringXPath(XPATH_URL, DEFAULT_URL); | 186 Config.getStringXPath(XPATH_URL, DEFAULT_URL); |
187 String connectionInitSqls = | |
188 Config.getStringXPath( | |
189 XPATH_CONNECTION_INIT_SQLS, | |
190 DEFAULT_CONNECTION_INIT_SQLS); | |
179 | 191 |
180 instance = new SedDBCredentials( | 192 instance = new SedDBCredentials( |
181 user, password, dialect, driver, url); | 193 user, password, dialect, driver, connectionInitSqls, url); |
182 } | 194 } |
183 return instance; | 195 return instance; |
184 } | 196 } |
185 | 197 |
186 public static Credentials getDefault() { | 198 public static Credentials getDefault() { |
187 return new SedDBCredentials( | 199 return new SedDBCredentials( |
188 DEFAULT_USER, | 200 DEFAULT_USER, |
189 DEFAULT_PASSWORD, | 201 DEFAULT_PASSWORD, |
190 DEFAULT_DIALECT, | 202 DEFAULT_DIALECT, |
191 DEFAULT_DRIVER, | 203 DEFAULT_DRIVER, |
192 DEFAULT_URL); | 204 DEFAULT_URL, |
205 DEFAULT_CONNECTION_INIT_SQLS); | |
193 } | 206 } |
194 } | 207 } |
195 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 208 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |