svn-gvsig-desktop / trunk / extensions / extSDE / src / com / iver / cit / gvsig / sde / gui / sdewizard2 / ConnectionSettings.java @ 11193
History | View | Annotate | Download (4.05 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL
|
34 |
* Conde Salvatierra de ?lava , 34-10
|
35 |
* 46004 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963 510 612
|
39 |
* +34 963 510 968
|
40 |
* gis@prodevelop.es
|
41 |
* http://www.prodevelop.es
|
42 |
*/
|
43 |
package com.iver.cit.gvsig.sde.gui.sdewizard2; |
44 |
|
45 |
import com.hardcode.driverManager.DriverLoadException; |
46 |
import com.iver.cit.gvsig.fmap.drivers.DefaultDBDriver; |
47 |
import com.iver.cit.gvsig.fmap.drivers.VectorialJDBCDriver; |
48 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
49 |
|
50 |
|
51 |
/**
|
52 |
*
|
53 |
* Utility class. Keeps connection parameters.
|
54 |
*
|
55 |
* @author jldominguez
|
56 |
* @author Fernando Gonz?lez Cort?s
|
57 |
*/
|
58 |
public class ConnectionSettings { |
59 |
private String host; |
60 |
private String port; |
61 |
private String db; |
62 |
private String driver; |
63 |
private String user; |
64 |
private String name; |
65 |
private String passw = null; |
66 |
|
67 |
public String getDb() { |
68 |
return db;
|
69 |
} |
70 |
|
71 |
public void setDb(String db) { |
72 |
this.db = db;
|
73 |
} |
74 |
|
75 |
public String getDriver() { |
76 |
return driver;
|
77 |
} |
78 |
|
79 |
public void setDriver(String driver) { |
80 |
this.driver = driver;
|
81 |
} |
82 |
|
83 |
public String getHost() { |
84 |
return host;
|
85 |
} |
86 |
|
87 |
public void setHost(String host) { |
88 |
this.host = host;
|
89 |
} |
90 |
|
91 |
public String getPort() { |
92 |
return port;
|
93 |
} |
94 |
|
95 |
public void setPort(String port) { |
96 |
this.port = port;
|
97 |
} |
98 |
|
99 |
public String getUser() { |
100 |
return user;
|
101 |
} |
102 |
|
103 |
public void setUser(String user) { |
104 |
this.user = user;
|
105 |
} |
106 |
|
107 |
public void setName(String name) { |
108 |
this.name = name;
|
109 |
} |
110 |
|
111 |
public String getName() { |
112 |
return name;
|
113 |
} |
114 |
|
115 |
public String toString() { |
116 |
return host + "," + port + "," + db + "," + driver + "," + user + "," + |
117 |
name; |
118 |
} |
119 |
|
120 |
public void setFromString(String _str) throws Exception { |
121 |
String str = _str;
|
122 |
if (str.endsWith(",")) str = str + " "; |
123 |
if (str.startsWith(",")) str = " " + str; |
124 |
|
125 |
String[] values = str.split(","); |
126 |
host = values[0];
|
127 |
port = values[1];
|
128 |
db = values[2];
|
129 |
driver = values[3];
|
130 |
user = values[4];
|
131 |
name = values[5];
|
132 |
|
133 |
if (values.length == 7) { |
134 |
passw = values[6];
|
135 |
} |
136 |
} |
137 |
|
138 |
public String getPassw() { |
139 |
return passw;
|
140 |
} |
141 |
|
142 |
public void setPassw(String passw) { |
143 |
this.passw = passw;
|
144 |
} |
145 |
|
146 |
public String getConnectionString() throws DriverLoadException { |
147 |
VectorialJDBCDriver vecDriver = (VectorialJDBCDriver) LayerFactory.getDM() |
148 |
.getDriver(getDriver()); |
149 |
|
150 |
if (vecDriver instanceof DefaultDBDriver) { |
151 |
return ((DefaultDBDriver) vecDriver).getConnectionString(getHost(),
|
152 |
getPort(), getDb(), getUser(), getPassw()); |
153 |
} |
154 |
|
155 |
String connectionString = vecDriver.getConnectionStringBeginning() +
|
156 |
"//" + getHost();
|
157 |
connectionString += (":" + getPort());
|
158 |
connectionString += ("/" + getDb());
|
159 |
|
160 |
return connectionString;
|
161 |
} |
162 |
} |