Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/utils/MapUtils.java @ 5508:c6e552348934
SedimentDensityParser: don't try to guess year from comment column
author | Tom Gottfried <tom.gottfried@intevation.de> |
---|---|
date | Thu, 28 Mar 2013 16:43:20 +0100 |
parents | eb7a3f58bdd6 |
children |
rev | line source |
---|---|
4841
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.utils; |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
2 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
3 import java.util.regex.Matcher; |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
4 import java.util.regex.Pattern; |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
5 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
6 import org.apache.log4j.Logger; |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
7 import org.hibernate.impl.SessionFactoryImpl; |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
8 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.flys.backend.SessionFactoryProvider; |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 public class MapUtils |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 { |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 private static final Logger logger = Logger.getLogger(MapUtils.class); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
15 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
16 public static final Pattern DB_URL_PATTERN = |
5211
9e11599266c8
Allow dots and numbers in oracle backend name
Andre Heinecke <aheinecke@intevation.de>
parents:
5147
diff
changeset
|
17 Pattern.compile("(.*)\\/\\/(.*):([0-9]+)\\/([\\.a-zA-Z0-9_-]+)"); |
4841
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
18 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
19 public static final Pattern DB_PSQL_URL_PATTERN = |
5147
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
20 Pattern.compile("(.*)\\/\\/(.*):([0-9]+)\\/([a-zA-Z0-9_-]+)"); |
4841
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
22 /** |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 * This method returns a connection string for databases used by |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 * Mapserver's Mapfile. |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 * |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
26 * @return A connection string for Mapserver. |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 */ |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 public static String getConnection() { |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 SessionFactoryImpl sf = (SessionFactoryImpl) |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 SessionFactoryProvider.getSessionFactory(); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
32 String user = SessionFactoryProvider.getUser(sf); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
33 String pass = SessionFactoryProvider.getPass(sf); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 String url = SessionFactoryProvider.getURL(sf); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
36 logger.debug("Parse connection url: " + url); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 Matcher m = DB_URL_PATTERN.matcher(url); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 if (!m.matches()) { |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 logger.warn("Could not parse Connection string." + |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
41 "Try to parse PostgreSQL string."); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 // maybe this is a PostgreSQL connection... |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
43 return getPostgreSQLConnection(); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 } |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 logger.debug("Groups for connection string: " + m.groupCount()); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
47 int groups = m.groupCount(); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 |
5147
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
49 |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
50 if (logger.isDebugEnabled()) { |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
51 for (int i = 0; i <= groups; i++) { |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
52 logger.debug("Group " + i + ": " + m.group(i)); |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
53 } |
4841
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 } |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
56 String connection = null; |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 if (FLYSUtils.isUsingOracle()) { |
5270
d17e3106c910
An oracle conection string needs a backend otherwise you get an error
Andre Heinecke <aheinecke@intevation.de>
parents:
5211
diff
changeset
|
59 if (groups < 4) { |
4841
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
60 logger.warn("Could only partially parse connection string."); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
61 return null; |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
62 } |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 String host = m.group(2); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
65 String port = m.group(3); |
5270
d17e3106c910
An oracle conection string needs a backend otherwise you get an error
Andre Heinecke <aheinecke@intevation.de>
parents:
5211
diff
changeset
|
66 String backend = m.group(4); |
5422
eb7a3f58bdd6
Add port info to generated connection string for oracle
Andre Heinecke <aheinecke@intevation.de>
parents:
5270
diff
changeset
|
67 connection = user + "/" + pass + "@" + host + ":" + port + "/" + backend; |
4841
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
68 } |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
69 else { |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
70 if (groups < 4) { |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
71 logger.warn("Could only partially parse connection string."); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
72 return null; |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
73 } |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
74 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
75 String host = m.group(2); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
76 String port = m.group(3); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
77 String db = m.group(4); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
78 |
5147
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
79 connection = createConnectionString(user, pass, host, db, port); |
4841
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
80 } |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
81 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
82 return connection; |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
83 } |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
84 |
5147
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
85 public static String createConnectionString( |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
86 String user, |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
87 String pass, |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
88 String host, |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
89 String db, |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
90 String port |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
91 ) { |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
92 StringBuilder sb = new StringBuilder(); |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
93 sb.append("dbname=").append(db); |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
94 sb.append(" host='").append(host).append("'"); |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
95 sb.append(" user=").append(user); |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
96 sb.append(" port=").append(port); |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
97 // XXX: We need to escape this somehow. |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
98 sb.append(" password='").append(pass).append("'"); |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
99 sb.append(" sslmode=disable"); |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
100 return sb.toString(); |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
101 } |
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
102 |
4841
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
103 protected static String getPostgreSQLConnection() { |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
104 SessionFactoryImpl sf = (SessionFactoryImpl) |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
105 SessionFactoryProvider.getSessionFactory(); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
106 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
107 String user = SessionFactoryProvider.getUser(sf); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
108 String pass = SessionFactoryProvider.getPass(sf); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
109 String url = SessionFactoryProvider.getURL(sf); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
110 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
111 Matcher m = DB_PSQL_URL_PATTERN.matcher(url); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
112 if (!m.matches()) { |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
113 logger.warn("Could not parse PostgreSQL Connection string."); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
114 return null; |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
115 } |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
116 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
117 int groups = m.groupCount(); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
118 logger.debug("Groups for PostgreSQL connection string: " + groups); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
119 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
120 if (logger.isDebugEnabled()) { |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
121 for (int i = 0; i <= groups; i++) { |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
122 logger.debug("Group " + i + ": " + m.group(i)); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
123 } |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
124 } |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
125 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
126 String connection = null; |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
127 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
128 if (groups < 4) { |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
129 logger.warn("Could only partially parse connection string."); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
130 return null; |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
131 } |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
132 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
133 String host = m.group(2); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
134 String port = m.group(3); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
135 String db = m.group(4); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
136 |
5147
48b231a02d3a
Generate valid DB connection strings.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4841
diff
changeset
|
137 connection = createConnectionString(user, pass, host, db, port); |
4841
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
138 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
139 logger.debug("Created connection: '" + connection + "'"); |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
140 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
141 return connection; |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
142 } |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
143 |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
144 public static String getConnectionType() { |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
145 return FLYSUtils.isUsingOracle() ? "oraclespatial" : "postgis"; |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
146 } |
ad0990a82ab8
Insert db connection into riveraxis map files.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
147 } |