Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/backend/SedDBCredentials.java @ 8470:c5a7aae52396
Added a validation SQL query to database backends.
Enable it by storing something like "SELECT 1 FROM DUAL" in config
under /artifact-database/backend-database/validation-query/text()
or /artifact-database/seddb-database/validation-query/text().
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 12 Nov 2014 13:31:53 +0100 |
parents | 4c3ccf2b0304 |
children | 026f4c684ee5 |
comparison
equal
deleted
inserted
replaced
8469:079147282650 | 8470:c5a7aae52396 |
---|---|
82 "/artifact-database/seddb-database/url/text()"; | 82 "/artifact-database/seddb-database/url/text()"; |
83 | 83 |
84 public static final String XPATH_CONNECTION_INIT_SQLS = | 84 public static final String XPATH_CONNECTION_INIT_SQLS = |
85 "/artifact-database/seddb-database/connection-init-sqls/text()"; | 85 "/artifact-database/seddb-database/connection-init-sqls/text()"; |
86 | 86 |
87 public static final String XPATH_VALIDATION_QUERY = | |
88 "/artifact-database/seddb-database/validation-query/text()"; | |
89 | |
87 public static final String DEFAULT_USER = | 90 public static final String DEFAULT_USER = |
88 System.getProperty("flys.seddb.user", "seddb"); | 91 System.getProperty("flys.seddb.user", "seddb"); |
89 | 92 |
90 public static final String DEFAULT_PASSWORD = | 93 public static final String DEFAULT_PASSWORD = |
91 System.getProperty("flys.seddb.password", "seddb"); | 94 System.getProperty("flys.seddb.password", "seddb"); |
106 "jdbc:postgresql://localhost:5432/seddb"); | 109 "jdbc:postgresql://localhost:5432/seddb"); |
107 | 110 |
108 public static final String DEFAULT_CONNECTION_INIT_SQLS = | 111 public static final String DEFAULT_CONNECTION_INIT_SQLS = |
109 System.getProperty( | 112 System.getProperty( |
110 "flys.seddb.connection.init.sqls"); | 113 "flys.seddb.connection.init.sqls"); |
114 | |
115 public static final String DEFAULT_VALIDATION_QUERY = | |
116 System.getProperty( | |
117 "flys.seddb.connection.validation.query"); | |
111 | 118 |
112 public static final Class [] CLASSES = { | 119 public static final Class [] CLASSES = { |
113 BezugspegelgewId.class, | 120 BezugspegelgewId.class, |
114 Bezugspegelgew.class, | 121 Bezugspegelgew.class, |
115 Bezugspegel.class, | 122 Bezugspegel.class, |
173 String user, | 180 String user, |
174 String password, | 181 String password, |
175 String dialect, | 182 String dialect, |
176 String driver, | 183 String driver, |
177 String url, | 184 String url, |
178 String connectionInitSqls | 185 String connectionInitSqls, |
186 String validationQuery | |
179 ) { | 187 ) { |
180 super( | 188 super( |
181 user, password, dialect, driver, url, connectionInitSqls, CLASSES); | 189 user, password, dialect, driver, url, |
190 connectionInitSqls, validationQuery, CLASSES); | |
182 } | 191 } |
183 | 192 |
184 public static synchronized Credentials getInstance() { | 193 public static synchronized Credentials getInstance() { |
185 if (instance == null) { | 194 if (instance == null) { |
186 String user = | 195 String user = |
195 Config.getStringXPath(XPATH_URL, DEFAULT_URL); | 204 Config.getStringXPath(XPATH_URL, DEFAULT_URL); |
196 String connectionInitSqls = | 205 String connectionInitSqls = |
197 Config.getStringXPath( | 206 Config.getStringXPath( |
198 XPATH_CONNECTION_INIT_SQLS, | 207 XPATH_CONNECTION_INIT_SQLS, |
199 DEFAULT_CONNECTION_INIT_SQLS); | 208 DEFAULT_CONNECTION_INIT_SQLS); |
209 String validationQuery = | |
210 Config.getStringXPath( | |
211 XPATH_VALIDATION_QUERY, | |
212 DEFAULT_VALIDATION_QUERY); | |
200 | 213 |
201 instance = new SedDBCredentials( | 214 instance = new SedDBCredentials( |
202 user, password, dialect, driver, url, connectionInitSqls); | 215 user, password, dialect, driver, url, |
216 connectionInitSqls, validationQuery); | |
203 } | 217 } |
204 return instance; | 218 return instance; |
205 } | 219 } |
206 | 220 |
207 public static Credentials getDefault() { | 221 public static Credentials getDefault() { |
209 DEFAULT_USER, | 223 DEFAULT_USER, |
210 DEFAULT_PASSWORD, | 224 DEFAULT_PASSWORD, |
211 DEFAULT_DIALECT, | 225 DEFAULT_DIALECT, |
212 DEFAULT_DRIVER, | 226 DEFAULT_DRIVER, |
213 DEFAULT_URL, | 227 DEFAULT_URL, |
214 DEFAULT_CONNECTION_INIT_SQLS); | 228 DEFAULT_CONNECTION_INIT_SQLS, |
229 DEFAULT_VALIDATION_QUERY); | |
215 } | 230 } |
216 } | 231 } |
217 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 232 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |