svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.geodb.app / org.gvsig.geodb.app.mainplugin / src / main / java / org / gvsig / geodb / vectorialdb / ConnectionSettings.java @ 40557
History | View | Annotate | Download (3.5 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.geodb.vectorialdb; |
25 |
|
26 |
import org.gvsig.fmap.dal.DALLocator; |
27 |
import org.gvsig.fmap.dal.DataManager; |
28 |
import org.gvsig.fmap.dal.exception.InitializeException; |
29 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
30 |
import org.gvsig.fmap.dal.resource.db.DBParameters; |
31 |
|
32 |
|
33 |
/**
|
34 |
* @author Fernando Gonz?lez Cort?s
|
35 |
*/
|
36 |
public class ConnectionSettings { |
37 |
private String host; |
38 |
private String port; |
39 |
private String db; |
40 |
private String schema; |
41 |
private String driver; |
42 |
private String user; |
43 |
private String name; |
44 |
private String passw; |
45 |
|
46 |
public String getDb() { |
47 |
return db;
|
48 |
} |
49 |
public void setDb(String db) { |
50 |
this.db = db;
|
51 |
} |
52 |
public String getDriver() { |
53 |
return driver;
|
54 |
} |
55 |
public void setDriver(String driver) { |
56 |
this.driver = driver;
|
57 |
} |
58 |
public String getHost() { |
59 |
return host;
|
60 |
} |
61 |
public void setHost(String host) { |
62 |
this.host = host;
|
63 |
} |
64 |
public String getPort() { |
65 |
return port;
|
66 |
} |
67 |
public void setPort(String port) { |
68 |
this.port = port;
|
69 |
} |
70 |
public String getUser() { |
71 |
return user;
|
72 |
} |
73 |
public void setUser(String user) { |
74 |
this.user = user;
|
75 |
} |
76 |
public void setName(String name) { |
77 |
this.name = name;
|
78 |
} |
79 |
public String getName() { |
80 |
return name;
|
81 |
} |
82 |
|
83 |
public String toString(){ |
84 |
return host+","+port+","+db+","+driver+","+user+","+name; |
85 |
} |
86 |
|
87 |
public void setFromString(String str) { |
88 |
String[] values = str.split(","); |
89 |
host = values[0];
|
90 |
port = values[1];
|
91 |
db = values[2];
|
92 |
driver = values[3];
|
93 |
user = values[4];
|
94 |
name = values[5];
|
95 |
if (values.length == 7) { |
96 |
passw = values[6];
|
97 |
} |
98 |
} |
99 |
public String getPassw() { |
100 |
return passw;
|
101 |
} |
102 |
public void setPassw(String passw) { |
103 |
this.passw = passw;
|
104 |
} |
105 |
public String getConnectionString(){ |
106 |
DataManager dm=DALLocator.getDataManager(); |
107 |
try {
|
108 |
DBParameters dsp=(DBParameters)dm.createStoreParameters(getDriver()); |
109 |
} catch (InitializeException e) {
|
110 |
// TODO Auto-generated catch block
|
111 |
e.printStackTrace(); |
112 |
} catch (ProviderNotRegisteredException e) {
|
113 |
// TODO Auto-generated catch block
|
114 |
e.printStackTrace(); |
115 |
} |
116 |
|
117 |
String connectionString = "";//vecDriver.getConnectionStringBeginning() + "//" + getHost(); |
118 |
|
119 |
connectionString += (":" + getPort());
|
120 |
|
121 |
connectionString += ("/" + getDb());
|
122 |
|
123 |
return connectionString;
|
124 |
} |
125 |
public String getSchema() { |
126 |
return schema;
|
127 |
} |
128 |
public void setSchema(String schema) { |
129 |
this.schema = schema;
|
130 |
} |
131 |
} |