Revision 43788
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.fmap.dal.store.mdb.MdbLibrary |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/resources/org/gvsig/fmap/dal/store/mdb/MdbMetadata.xml | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<definitions> |
|
3 |
<version>1.0.0</version> |
|
4 |
<classes> |
|
5 |
<class name="H2Spatial" namespace="Metadata"> |
|
6 |
<extends> |
|
7 |
<class name="JDBC2" namespace="Metadata"/> |
|
8 |
</extends> |
|
9 |
<description>Metadata of a H2 store</description> |
|
10 |
<fields> |
|
11 |
</fields> |
|
12 |
</class> |
|
13 |
|
|
14 |
</classes> |
|
15 |
</definitions> |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/resources/org/gvsig/fmap/dal/store/mdb/MdbParameters.xml | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<definitions> |
|
3 |
<version>1.0.0</version> |
|
4 |
<classes> |
|
5 |
<class name="H2SpatialResourceParameters"> |
|
6 |
<extends> |
|
7 |
<class>JDBC2ResourceParameters</class> |
|
8 |
</extends> |
|
9 |
<fields> |
|
10 |
<field name="JDBCDriverClass" type="string" mandatory="true" |
|
11 |
defaultValue="org.h2.Driver" group="Advanced"> |
|
12 |
<description>JDBC Driver class</description> |
|
13 |
</field> |
|
14 |
<field name="port" type="integer" mandatory="false" |
|
15 |
defaultValue="9123" group="Connection"> |
|
16 |
<description></description> |
|
17 |
</field> |
|
18 |
<field name="database_file" label="Database file" type="file" mandatory="true" defaultValue="" group="Basic"> |
|
19 |
<description></description> |
|
20 |
</field> |
|
21 |
<field name="UseSSL" type="boolean" mandatory="false" |
|
22 |
defaultValue="false" group="Basic"> |
|
23 |
<description>Use SSL connetion</description> |
|
24 |
</field> |
|
25 |
<field name="dbuser" type="string" mandatory="false" group="Basic" defaultValue="SA" > |
|
26 |
<description></description> |
|
27 |
</field> |
|
28 |
</fields> |
|
29 |
</class> |
|
30 |
|
|
31 |
<class name="H2SpatialStoreParameters"> |
|
32 |
<extends> |
|
33 |
<class>JDBC2StoreParameters</class> |
|
34 |
<class>H2SpatialResourceParameters</class> |
|
35 |
</extends> |
|
36 |
<fields/> |
|
37 |
</class> |
|
38 |
|
|
39 |
<class name="H2SpatialNewStoreParameters"> |
|
40 |
<extends> |
|
41 |
<class>JDBC2NewStoreParameters</class> |
|
42 |
<class>H2SpatialResourceParameters</class> |
|
43 |
</extends> |
|
44 |
<fields/> |
|
45 |
</class> |
|
46 |
|
|
47 |
|
|
48 |
<class name="H2SpatialServerExplorerParameters"> |
|
49 |
<extends> |
|
50 |
<class>H2SpatialResourceParameters</class> |
|
51 |
<class>JDBC2ServerExplorerParameters</class> |
|
52 |
</extends> |
|
53 |
<fields/> |
|
54 |
</class> |
|
55 |
|
|
56 |
|
|
57 |
</classes> |
|
58 |
</definitions> |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/java/org/gvsig/fmap/dal/store/mdb/MdbExplorerFactory.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.fmap.dal.store.mdb; |
|
3 |
|
|
4 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
5 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
6 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
|
7 |
import org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters; |
|
8 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.impl.JDBCServerExplorerFactory; |
|
12 |
|
|
13 |
|
|
14 |
public class MdbExplorerFactory extends JDBCServerExplorerFactory { |
|
15 |
|
|
16 |
public MdbExplorerFactory() { |
|
17 |
super( |
|
18 |
MdbLibrary.NAME, |
|
19 |
"Mdb" |
|
20 |
); |
|
21 |
} |
|
22 |
|
|
23 |
@Override |
|
24 |
public JDBCServerExplorer create( |
|
25 |
DataServerExplorerParameters parameters, |
|
26 |
DataServerExplorerProviderServices providerServices |
|
27 |
) throws InitializeException { |
|
28 |
JDBCHelper helper = new MdbHelper((JDBCConnectionParameters) parameters); |
|
29 |
JDBCServerExplorer server = helper.createServerExplorer( |
|
30 |
(JDBCServerExplorerParameters) parameters, |
|
31 |
providerServices |
|
32 |
); |
|
33 |
return server; |
|
34 |
} |
|
35 |
|
|
36 |
|
|
37 |
@Override |
|
38 |
public JDBCServerExplorerParameters createParameters() { |
|
39 |
JDBCServerExplorerParameters params = new MdbExplorerParameters(); |
|
40 |
return params; |
|
41 |
} |
|
42 |
|
|
43 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/java/org/gvsig/fmap/dal/store/mdb/MdbNewStoreParameters.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.fmap.dal.store.mdb; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.util.Properties; |
|
26 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
27 |
import org.gvsig.fmap.dal.store.jdbc.JDBCNewStoreParameters; |
|
28 |
|
|
29 |
public class MdbNewStoreParameters |
|
30 |
extends |
|
31 |
JDBCNewStoreParameters |
|
32 |
implements |
|
33 |
MdbConnectionParameters |
|
34 |
{ |
|
35 |
|
|
36 |
private final MdbConnectionParametersHelper helper; |
|
37 |
|
|
38 |
public MdbNewStoreParameters() { |
|
39 |
super( |
|
40 |
MdbLibrary.NAME + "NewStoreParameters", |
|
41 |
MdbLibrary.NAME |
|
42 |
); |
|
43 |
this.helper = new MdbConnectionParametersHelper(this); |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public String getUrl() { |
|
48 |
return this.helper.getUrl(); |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public void validate() throws ValidateDataParametersException { |
|
53 |
this.helper.validate(); |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
public Properties getProperties() { |
|
58 |
return this.helper.getProperties(); |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
public File getFile() { |
|
63 |
return this.helper.getFile(); |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
public void setFile(File database) { |
|
68 |
this.helper.setFile(database); |
|
69 |
} |
|
70 |
|
|
71 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/java/org/gvsig/fmap/dal/store/mdb/MdbHelper.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2016 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 |
*/ |
|
22 |
package org.gvsig.fmap.dal.store.mdb; |
|
23 |
|
|
24 |
import java.sql.Connection; |
|
25 |
import java.sql.SQLException; |
|
26 |
import java.text.MessageFormat; |
|
27 |
import org.apache.commons.dbcp.BasicDataSource; |
|
28 |
import org.apache.commons.io.FilenameUtils; |
|
29 |
import org.apache.commons.lang3.StringUtils; |
|
30 |
import org.gvsig.fmap.dal.SQLBuilder; |
|
31 |
import org.gvsig.fmap.dal.resource.exception.AccessResourceException; |
|
32 |
import org.gvsig.fmap.dal.store.mdb.operations.MdbOperationsFactory; |
|
33 |
import org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters; |
|
34 |
import org.gvsig.fmap.dal.store.jdbc.JDBCNewStoreParameters; |
|
35 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
|
36 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
37 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCDriverClassNotFoundException; |
|
38 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
39 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCHelperBase; |
|
40 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
41 |
import org.gvsig.fmap.dal.store.jdbc2.spi.SRSSolverBase; |
|
42 |
|
|
43 |
import org.slf4j.Logger; |
|
44 |
import org.slf4j.LoggerFactory; |
|
45 |
|
|
46 |
public class MdbHelper extends JDBCHelperBase { |
|
47 |
|
|
48 |
static final Logger logger = LoggerFactory.getLogger(MdbHelper.class); |
|
49 |
|
|
50 |
public static final String MdbJDBCDriver = "org.h2.Driver"; |
|
51 |
|
|
52 |
public static String getConnectionURL(MdbConnectionParameters params) { |
|
53 |
String connectionURL; |
|
54 |
if( StringUtils.isEmpty(params.getHost()) ) { |
|
55 |
// Asumimos que es una conexion directa sobre el filesystem |
|
56 |
String dbname = params.getFile().getAbsolutePath().replace("\\","/"); |
|
57 |
if( StringUtils.equalsIgnoreCase(FilenameUtils.getExtension(params.getFile().getName()),"zip") ) { |
|
58 |
connectionURL = MessageFormat.format( |
|
59 |
"jdbc:h2:zip:{0}!/{1};MODE=PostgreSQL", |
|
60 |
dbname, |
|
61 |
params.getDBName() |
|
62 |
); |
|
63 |
} else { |
|
64 |
if( dbname.endsWith(".mv.db") ) { |
|
65 |
dbname = dbname.substring(0, dbname.length()-6); |
|
66 |
} |
|
67 |
connectionURL = MessageFormat.format( |
|
68 |
"jdbc:h2:file:{0};MODE=PostgreSQL", |
|
69 |
dbname |
|
70 |
); |
|
71 |
} |
|
72 |
} else if( params.getPort() == null ) { |
|
73 |
connectionURL = MessageFormat.format( |
|
74 |
"jdbc:h2:tcp://{0}/{1};MODE=PostgreSQL", |
|
75 |
params.getHost(), |
|
76 |
params.getDBName() |
|
77 |
); |
|
78 |
} else { |
|
79 |
connectionURL = MessageFormat.format( |
|
80 |
"jdbc:h2:tcp://{0}:{1,number,#######}/{2};MODE=PostgreSQL", |
|
81 |
params.getHost(), |
|
82 |
params.getPort().intValue(), |
|
83 |
params.getDBName() |
|
84 |
); |
|
85 |
} |
|
86 |
logger.debug("connectionURL: {}", connectionURL); |
|
87 |
return connectionURL; |
|
88 |
} |
|
89 |
|
|
90 |
private static class ConnectionProvider { |
|
91 |
|
|
92 |
private static boolean needRegisterDriver = true; |
|
93 |
|
|
94 |
private BasicDataSource dataSource = null; |
|
95 |
|
|
96 |
private final MdbConnectionParameters connectionParameters; |
|
97 |
|
|
98 |
public ConnectionProvider(MdbConnectionParameters connectionParameters) { |
|
99 |
this.connectionParameters = connectionParameters; |
|
100 |
} |
|
101 |
|
|
102 |
@Override |
|
103 |
public String toString() { |
|
104 |
StringBuilder builder = new StringBuilder(); |
|
105 |
builder.append(" url=").append(connectionParameters.getUrl()); |
|
106 |
builder.append(" driver name=").append(connectionParameters.getJDBCDriverClassName()); |
|
107 |
builder.append(" user=").append(connectionParameters.getUser()); |
|
108 |
return builder.toString(); |
|
109 |
} |
|
110 |
|
|
111 |
public Connection getConnection() throws SQLException { |
|
112 |
if (this.dataSource == null) { |
|
113 |
this.dataSource = this.createDataSource(); |
|
114 |
} |
|
115 |
Connection conn = this.dataSource.getConnection(); |
|
116 |
try { |
|
117 |
conn.createStatement().execute("SELECT TOP 1 SRID FROM SPATIAL_REF_SYS"); |
|
118 |
} catch(SQLException ex) { |
|
119 |
H2GISExtension.load(conn); |
|
120 |
} |
|
121 |
return conn; |
|
122 |
} |
|
123 |
|
|
124 |
private BasicDataSource createDataSource() throws SQLException { |
|
125 |
if (!this.isRegistered()) { |
|
126 |
this.registerDriver(); |
|
127 |
} |
|
128 |
MdbConnectionParameters params = connectionParameters; |
|
129 |
|
|
130 |
BasicDataSource ds = new BasicDataSource(); |
|
131 |
ds.setDriverClassName(params.getJDBCDriverClassName()); |
|
132 |
if( !StringUtils.isEmpty(params.getUser()) ) { |
|
133 |
ds.setUsername(params.getUser()); |
|
134 |
} |
|
135 |
if( !StringUtils.isEmpty(params.getPassword()) ) { |
|
136 |
ds.setPassword(params.getPassword()); |
|
137 |
} |
|
138 |
ds.setUrl(params.getUrl()); |
|
139 |
|
|
140 |
ds.setMaxWait(60L * 1000); |
|
141 |
return ds; |
|
142 |
} |
|
143 |
|
|
144 |
private boolean isRegistered() { |
|
145 |
return needRegisterDriver; |
|
146 |
} |
|
147 |
|
|
148 |
public void registerDriver() throws SQLException { |
|
149 |
String className = this.connectionParameters.getJDBCDriverClassName(); |
|
150 |
if (className == null) { |
|
151 |
return; |
|
152 |
} |
|
153 |
try { |
|
154 |
Class theClass = Class.forName(className); |
|
155 |
if (theClass == null) { |
|
156 |
throw new JDBCDriverClassNotFoundException(MdbLibrary.NAME, className); |
|
157 |
} |
|
158 |
} catch (Exception e) { |
|
159 |
throw new SQLException("Can't register JDBC driver '" + className + "'.", e); |
|
160 |
} |
|
161 |
needRegisterDriver = false; |
|
162 |
} |
|
163 |
|
|
164 |
} |
|
165 |
|
|
166 |
// private static class ConnectionProvider { |
|
167 |
// |
|
168 |
// private static boolean needRegisterDriver = true; |
|
169 |
// |
|
170 |
// |
|
171 |
// private final MdbConnectionParameters connectionParameters; |
|
172 |
// |
|
173 |
// public ConnectionProvider(MdbConnectionParameters connectionParameters) { |
|
174 |
// this.connectionParameters = connectionParameters; |
|
175 |
// } |
|
176 |
// |
|
177 |
// public Connection getConnection() throws SQLException { |
|
178 |
// if (!this.isRegistered()) { |
|
179 |
// this.registerDriver(); |
|
180 |
// } |
|
181 |
// Connection conn; |
|
182 |
// if( !StringUtils.isEmpty(connectionParameters.getUser()) ) { |
|
183 |
// conn = DriverManager.getConnection( |
|
184 |
// connectionParameters.getUrl(), |
|
185 |
// connectionParameters.getUser(), |
|
186 |
// connectionParameters.getPassword() |
|
187 |
// ); |
|
188 |
// } else { |
|
189 |
// conn = DriverManager.getConnection(connectionParameters.getUrl()); |
|
190 |
// } |
|
191 |
// try { |
|
192 |
// conn.createStatement().execute("SELECT TOP 1 SRID FROM SPATIAL_REF_SYS"); |
|
193 |
// } catch(SQLException ex) { |
|
194 |
// H2GISExtension.load(conn); |
|
195 |
// } |
|
196 |
// return conn; |
|
197 |
// } |
|
198 |
// |
|
199 |
// private boolean isRegistered() { |
|
200 |
// return needRegisterDriver; |
|
201 |
// } |
|
202 |
// |
|
203 |
// public void registerDriver() throws SQLException { |
|
204 |
// String className = this.connectionParameters.getJDBCDriverClassName(); |
|
205 |
// if (className == null) { |
|
206 |
// return; |
|
207 |
// } |
|
208 |
// try { |
|
209 |
// Class theClass = Class.forName(className); |
|
210 |
// if (theClass == null) { |
|
211 |
// throw new JDBCDriverClassNotFoundException(MdbLibrary.NAME, className); |
|
212 |
// } |
|
213 |
// } catch (Exception e) { |
|
214 |
// throw new SQLException("Can't register JDBC driver '" + className + "'.", e); |
|
215 |
// } |
|
216 |
// needRegisterDriver = false; |
|
217 |
// } |
|
218 |
// |
|
219 |
// } |
|
220 |
|
|
221 |
private ConnectionProvider connectionProvider = null; |
|
222 |
|
|
223 |
public MdbHelper(JDBCConnectionParameters connectionParameters) { |
|
224 |
super(connectionParameters); |
|
225 |
this.srssolver = new SRSSolverBase(this); |
|
226 |
} |
|
227 |
|
|
228 |
@Override |
|
229 |
public synchronized Connection getConnection() throws AccessResourceException { |
|
230 |
try { |
|
231 |
if (this.connectionProvider == null) { |
|
232 |
this.connectionProvider = new ConnectionProvider(this.getConnectionParameters()); |
|
233 |
} |
|
234 |
Connection connection = this.connectionProvider.getConnection(); |
|
235 |
if( logger.isDebugEnabled() ) { |
|
236 |
logger.debug("getConnection: connection = "+connection.hashCode()+ connectionProvider.toString()); |
|
237 |
} |
|
238 |
return connection; |
|
239 |
} catch (SQLException ex) { |
|
240 |
throw new AccessResourceException(MdbLibrary.NAME, ex); |
|
241 |
} |
|
242 |
} |
|
243 |
|
|
244 |
@Override |
|
245 |
public void closeConnection(Connection connection) { |
|
246 |
logger.debug("closeConnection: connection = "+connection.hashCode()); |
|
247 |
super.closeConnection(connection); |
|
248 |
} |
|
249 |
|
|
250 |
@Override |
|
251 |
public MdbConnectionParameters getConnectionParameters() { |
|
252 |
return (MdbConnectionParameters) super.getConnectionParameters(); |
|
253 |
} |
|
254 |
|
|
255 |
@Override |
|
256 |
public String getConnectionURL() { |
|
257 |
return getConnectionURL(this.getConnectionParameters()); |
|
258 |
} |
|
259 |
|
|
260 |
@Override |
|
261 |
protected String getResourceType() { |
|
262 |
return MdbLibrary.NAME; |
|
263 |
} |
|
264 |
|
|
265 |
@Override |
|
266 |
public String getProviderName() { |
|
267 |
return MdbLibrary.NAME; |
|
268 |
} |
|
269 |
|
|
270 |
@Override |
|
271 |
public JDBCSQLBuilderBase createSQLBuilder() { |
|
272 |
return new MdbSQLBuilder(this); |
|
273 |
} |
|
274 |
|
|
275 |
@Override |
|
276 |
public OperationsFactory getOperations() { |
|
277 |
if (this.operationsFactory == null) { |
|
278 |
this.operationsFactory = new MdbOperationsFactory(this); |
|
279 |
} |
|
280 |
return operationsFactory; |
|
281 |
} |
|
282 |
|
|
283 |
@Override |
|
284 |
public SQLBuilder.GeometrySupportType getGeometrySupportType() { |
|
285 |
return SQLBuilder.GeometrySupportType.WKB; |
|
286 |
} |
|
287 |
|
|
288 |
@Override |
|
289 |
public boolean hasSpatialFunctions() { |
|
290 |
return true; |
|
291 |
} |
|
292 |
|
|
293 |
@Override |
|
294 |
public boolean canWriteGeometry(int geometryType, int geometrySubtype) { |
|
295 |
return true; |
|
296 |
} |
|
297 |
|
|
298 |
@Override |
|
299 |
public String getQuoteForIdentifiers() { |
|
300 |
return "\""; |
|
301 |
} |
|
302 |
|
|
303 |
@Override |
|
304 |
public boolean allowAutomaticValues() { |
|
305 |
return true; |
|
306 |
} |
|
307 |
|
|
308 |
@Override |
|
309 |
public boolean supportOffsetInSelect() { |
|
310 |
return true; |
|
311 |
} |
|
312 |
|
|
313 |
@Override |
|
314 |
public String getQuoteForStrings() { |
|
315 |
return "'"; |
|
316 |
} |
|
317 |
|
|
318 |
@Override |
|
319 |
public String getSourceId(JDBCStoreParameters parameters) { |
|
320 |
return parameters.getDBName() + "." + |
|
321 |
parameters.getSchema()+ "." + |
|
322 |
parameters.getTable(); |
|
323 |
} |
|
324 |
|
|
325 |
@Override |
|
326 |
public JDBCNewStoreParameters createNewStoreParameters() { |
|
327 |
return new MdbNewStoreParameters(); |
|
328 |
} |
|
329 |
|
|
330 |
@Override |
|
331 |
public JDBCStoreParameters createOpenStoreParameters() { |
|
332 |
return new MdbStoreParameters(); |
|
333 |
} |
|
334 |
|
|
335 |
@Override |
|
336 |
public JDBCServerExplorerParameters createServerExplorerParameters() { |
|
337 |
return new MdbExplorerParameters(); |
|
338 |
} |
|
339 |
|
|
340 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/java/org/gvsig/fmap/dal/store/mdb/MdbStoreProviderFactory.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.fmap.dal.store.mdb; |
|
3 |
|
|
4 |
import org.gvsig.fmap.dal.DataParameters; |
|
5 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
6 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
7 |
import org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters; |
|
8 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCStoreProvider; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.impl.JDBCStoreProviderFactory; |
|
12 |
|
|
13 |
|
|
14 |
public class MdbStoreProviderFactory extends JDBCStoreProviderFactory { |
|
15 |
|
|
16 |
private static final String NAME = MdbLibrary.NAME; |
|
17 |
|
|
18 |
public MdbStoreProviderFactory() { |
|
19 |
super( |
|
20 |
NAME, |
|
21 |
"Mdb store" |
|
22 |
); |
|
23 |
} |
|
24 |
|
|
25 |
@Override |
|
26 |
public JDBCStoreProvider createProvider( |
|
27 |
DataParameters parameters, |
|
28 |
DataStoreProviderServices providerServices |
|
29 |
) throws InitializeException { |
|
30 |
JDBCHelper helper = new MdbHelper((JDBCConnectionParameters) parameters); |
|
31 |
JDBCStoreProvider provider = helper.createProvider( |
|
32 |
(JDBCStoreParameters) parameters, |
|
33 |
providerServices |
|
34 |
); |
|
35 |
return provider; |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public JDBCStoreParameters createParameters() { |
|
40 |
JDBCStoreParameters params = new MdbStoreParameters(); |
|
41 |
return params; |
|
42 |
} |
|
43 |
|
|
44 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/java/org/gvsig/fmap/dal/store/mdb/MdbStoreParameters.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.fmap.dal.store.mdb; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.util.Properties; |
|
26 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
27 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
28 |
|
|
29 |
public class MdbStoreParameters extends JDBCStoreParameters implements MdbConnectionParameters { |
|
30 |
|
|
31 |
private final MdbConnectionParametersHelper helper; |
|
32 |
|
|
33 |
public MdbStoreParameters() { |
|
34 |
super( |
|
35 |
MdbLibrary.NAME + "StoreParameters", |
|
36 |
MdbLibrary.NAME |
|
37 |
); |
|
38 |
this.helper = new MdbConnectionParametersHelper(this); |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public String getUrl() { |
|
43 |
return this.helper.getUrl(); |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public void validate() throws ValidateDataParametersException { |
|
48 |
this.helper.validate(); |
|
49 |
super.validate(); |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public Properties getProperties() { |
|
54 |
return this.helper.getProperties(); |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public File getFile() { |
|
59 |
return this.helper.getFile(); |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public void setFile(File database) { |
|
64 |
this.helper.setFile(database); |
|
65 |
} |
|
66 |
|
|
67 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/java/org/gvsig/fmap/dal/store/mdb/operations/MdbListTablesOperation.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.store.mdb.operations; |
|
2 |
|
|
3 |
import java.sql.Connection; |
|
4 |
import java.sql.ResultSet; |
|
5 |
import java.sql.SQLException; |
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.List; |
|
8 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.ListTablesOperation; |
|
12 |
|
|
13 |
public class MdbListTablesOperation extends ListTablesOperation { |
|
14 |
|
|
15 |
public MdbListTablesOperation(JDBCHelper helper, int mode, JDBCStoreParameters baseParameters, boolean informationTables) { |
|
16 |
super(helper, mode, baseParameters, informationTables); |
|
17 |
} |
|
18 |
|
|
19 |
@Override |
|
20 |
public List<JDBCStoreParameters> listTables( |
|
21 |
Connection conn, |
|
22 |
int mode, |
|
23 |
JDBCStoreParameters baseParameters, |
|
24 |
boolean informationTables |
|
25 |
) { |
|
26 |
ResultSet rs = null; |
|
27 |
List<JDBCStoreParameters> tables = new ArrayList<>(); |
|
28 |
|
|
29 |
try { |
|
30 |
String sql = "SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES where table_type in ('TABLE','VIEW','EXTERNAL')"; |
|
31 |
rs = conn.createStatement().executeQuery(sql); |
|
32 |
while (rs.next()) { |
|
33 |
JDBCStoreParameters params = baseParameters.getCopy(); |
|
34 |
params.setCatalog(rs.getString("TABLE_CATALOG")); |
|
35 |
params.setSchema(rs.getString("TABLE_SCHEMA")); |
|
36 |
params.setTable(rs.getString("TABLE_NAME")); |
|
37 |
tables.add(params); |
|
38 |
} |
|
39 |
return tables; |
|
40 |
|
|
41 |
} catch (SQLException ex) { |
|
42 |
throw new RuntimeException("Can't fetch tables information",ex); |
|
43 |
|
|
44 |
} finally { |
|
45 |
JDBCUtils.closeQuietly(rs); |
|
46 |
} |
|
47 |
|
|
48 |
} |
|
49 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/java/org/gvsig/fmap/dal/store/mdb/operations/MdbAppendOperation.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.fmap.dal.store.mdb.operations; |
|
3 |
|
|
4 |
import java.sql.PreparedStatement; |
|
5 |
import java.sql.SQLException; |
|
6 |
import org.gvsig.fmap.dal.DataTypes; |
|
7 |
import org.gvsig.fmap.dal.exception.DataException; |
|
8 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
9 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
10 |
import org.gvsig.fmap.dal.feature.exception.AlreadyEditingException; |
|
11 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCPreparingSQLException; |
|
13 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
14 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
|
15 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.AppendOperation; |
|
16 |
import org.gvsig.tools.dispose.Disposable; |
|
17 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
18 |
|
|
19 |
|
|
20 |
public class MdbAppendOperation extends AppendOperation { |
|
21 |
|
|
22 |
public MdbAppendOperation( |
|
23 |
JDBCHelper helper, |
|
24 |
String database, |
|
25 |
String schema, |
|
26 |
String table, |
|
27 |
FeatureType type |
|
28 |
) { |
|
29 |
super(helper, database, schema, table, type); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public void begin() throws DataException { |
|
34 |
if (this.sqlbuilder != null) { |
|
35 |
throw new AlreadyEditingException(this.helper.getSourceId()); |
|
36 |
} |
|
37 |
|
|
38 |
try { |
|
39 |
this.connection = this.helper.getConnectionWritable(); |
|
40 |
|
|
41 |
this.sqlbuilder = this.helper.createSQLBuilder(); |
|
42 |
|
|
43 |
this.sqlbuilder.insert().table().database(this.database).schema(this.schema).name(this.table); |
|
44 |
for (FeatureAttributeDescriptor attr : type) { |
|
45 |
if( attr.isAutomatic() ) { |
|
46 |
continue; |
|
47 |
} |
|
48 |
if (attr.getType() == DataTypes.GEOMETRY) { |
|
49 |
this.sqlbuilder.insert().column().name(attr.getName()).with_value( |
|
50 |
sqlbuilder.parameter(attr.getName()).as_geometry_variable().srs( |
|
51 |
sqlbuilder.parameter().value(attr.getSRS()) |
|
52 |
) |
|
53 |
); |
|
54 |
} else { |
|
55 |
this.sqlbuilder.insert().column().name(attr.getName()).with_value( |
|
56 |
sqlbuilder.parameter(attr.getName()).as_variable() |
|
57 |
); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
PreparedStatement st; |
|
62 |
this.sql = this.sqlbuilder.insert().toString(); |
|
63 |
this.preparedStatement = this.connection.prepareStatement(sql); |
|
64 |
this.connection.setAutoCommit(false); |
|
65 |
JDBCUtils.execute(this.connection, "SET LOG 1"); |
|
66 |
JDBCUtils.execute(this.connection, "SET LOCK_MODE 1"); |
|
67 |
JDBCUtils.execute(this.connection, "SET UNDO_LOG 0"); |
|
68 |
|
|
69 |
} catch (SQLException ex) { |
|
70 |
throw new JDBCPreparingSQLException(this.sqlbuilder.toString(),ex); |
|
71 |
} |
|
72 |
|
|
73 |
} |
|
74 |
|
|
75 |
@Override |
|
76 |
protected void clean() { |
|
77 |
JDBCUtils.closeQuietly(this.preparedStatement); |
|
78 |
this.helper.closeConnection(this.connection); |
|
79 |
this.connection = null; |
|
80 |
this.preparedStatement = null; |
|
81 |
this.sqlbuilder = null; |
|
82 |
this.sql = null; |
|
83 |
} |
|
84 |
|
|
85 |
@Override |
|
86 |
public void end() { |
|
87 |
try { |
|
88 |
this.connection.commit(); |
|
89 |
JDBCUtils.execute(this.connection, "SET LOG 2"); |
|
90 |
JDBCUtils.execute(this.connection, "SET LOCK_MODE 3"); |
|
91 |
JDBCUtils.execute(this.connection, "SET UNDO_LOG 1"); |
|
92 |
} catch (SQLException ex) { |
|
93 |
try { |
|
94 |
this.connection.rollback(); |
|
95 |
} catch (SQLException ex1) { |
|
96 |
} |
|
97 |
throw new RuntimeException("Can't commit transaction", ex); |
|
98 |
} finally { |
|
99 |
clean(); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
@Override |
|
104 |
public void abort() { |
|
105 |
try { |
|
106 |
this.connection.rollback(); |
|
107 |
JDBCUtils.execute(this.connection, "SET LOG 2"); |
|
108 |
JDBCUtils.execute(this.connection, "SET LOCK_MODE 3"); |
|
109 |
JDBCUtils.execute(this.connection, "SET UNDO_LOG 1"); |
|
110 |
} catch (SQLException ex) { |
|
111 |
} |
|
112 |
clean(); |
|
113 |
} |
|
114 |
|
|
115 |
@Override |
|
116 |
public void append(FeatureProvider feature) throws DataException { |
|
117 |
int n; |
|
118 |
Disposable paramsDisposer = null; |
|
119 |
try { |
|
120 |
paramsDisposer = this.sqlbuilder.setParameters(this.preparedStatement, feature); |
|
121 |
n = JDBCUtils.executeUpdate(this.preparedStatement,this.sql); |
|
122 |
} catch(Exception ex) { |
|
123 |
throw new RuntimeException("Can't insert feature.", ex); |
|
124 |
} finally { |
|
125 |
DisposeUtils.disposeQuietly(paramsDisposer); |
|
126 |
} |
|
127 |
if( n<1 ) { |
|
128 |
throw new RuntimeException("Can't insert feature (n="+n+")."); |
|
129 |
} |
|
130 |
} |
|
131 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/java/org/gvsig/fmap/dal/store/mdb/operations/MdbFetchFeatureTypeOperation.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.fmap.dal.store.mdb.operations; |
|
3 |
|
|
4 |
import java.sql.Connection; |
|
5 |
import java.sql.ResultSet; |
|
6 |
import java.sql.ResultSetMetaData; |
|
7 |
import java.sql.SQLException; |
|
8 |
import java.sql.Statement; |
|
9 |
import java.util.HashMap; |
|
10 |
import java.util.List; |
|
11 |
import java.util.Map; |
|
12 |
import org.apache.commons.lang3.StringUtils; |
|
13 |
import org.cresques.cts.IProjection; |
|
14 |
import org.gvsig.fmap.dal.DataTypes; |
|
15 |
import org.gvsig.fmap.dal.exception.DataException; |
|
16 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
17 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
18 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
19 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
|
20 |
import org.gvsig.fmap.dal.store.jdbc2.spi.SRSSolver; |
|
21 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureTypeOperation; |
|
22 |
import org.gvsig.fmap.geom.Geometry; |
|
23 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
24 |
import org.gvsig.fmap.geom.GeometryManager; |
|
25 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
26 |
|
|
27 |
public class MdbFetchFeatureTypeOperation extends FetchFeatureTypeOperation { |
|
28 |
|
|
29 |
private static Map<String,GeometryType>h2spatialGeometryTypes = null; |
|
30 |
private Map<String,GeometryColumnInfo> geometry_column; |
|
31 |
|
|
32 |
private static class GeometryColumnInfo { |
|
33 |
|
|
34 |
public String columnName; |
|
35 |
public int geometryType; |
|
36 |
public String geometryTypeName; |
|
37 |
public int dimensions; |
|
38 |
public int srid; |
|
39 |
|
|
40 |
public GeometryColumnInfo(String columnName, int geometryType, String geometryTypeName, int dimensions, int srid) { |
|
41 |
this.columnName = columnName; |
|
42 |
this.geometryType = geometryType; |
|
43 |
this.geometryTypeName = geometryTypeName; |
|
44 |
this.dimensions = dimensions; |
|
45 |
this.srid = srid; |
|
46 |
} |
|
47 |
} |
|
48 |
|
|
49 |
|
|
50 |
public MdbFetchFeatureTypeOperation( |
|
51 |
JDBCHelper helper |
|
52 |
) { |
|
53 |
super(helper); |
|
54 |
} |
|
55 |
|
|
56 |
private GeometryType getGT( |
|
57 |
GeometryManager manager, |
|
58 |
int type, |
|
59 |
int subtype |
|
60 |
) { |
|
61 |
try { |
|
62 |
return manager.getGeometryType(type, subtype); |
|
63 |
} catch (Exception ex) { |
|
64 |
return null; |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 |
public MdbFetchFeatureTypeOperation( |
|
69 |
JDBCHelper helper, |
|
70 |
EditableFeatureType featureType, |
|
71 |
String dbname, |
|
72 |
String schema, |
|
73 |
String table, |
|
74 |
List<String> primaryKeys, |
|
75 |
String defaultGeometryColumn, |
|
76 |
IProjection crs |
|
77 |
) { |
|
78 |
super(helper, featureType, dbname, schema, table, primaryKeys, defaultGeometryColumn, crs); |
|
79 |
} |
|
80 |
|
|
81 |
@Override |
|
82 |
public void fetch(EditableFeatureType featureType, Connection conn, String dbname, String schema, String table, List<String> pks, String defaultGeometryColumn, IProjection crs) throws DataException { |
|
83 |
geometry_column = new HashMap<>(); |
|
84 |
try { |
|
85 |
// |
|
86 |
// https://github.com/orbisgis/h2gis/wiki/1.-Spatial-data#geometry-columns-view |
|
87 |
// |
|
88 |
StringBuilder where = null; |
|
89 |
if( !StringUtils.isEmpty(dbname) ) { |
|
90 |
if( where == null ) { |
|
91 |
where = new StringBuilder(); |
|
92 |
} else { |
|
93 |
where.append(" AND "); |
|
94 |
} |
|
95 |
where.append("UPPER(F_TABLE_CATALOG) = '"); |
|
96 |
where.append(dbname.toUpperCase()); |
|
97 |
where.append("'"); |
|
98 |
} |
|
99 |
if( !StringUtils.isEmpty(schema) ) { |
|
100 |
if( where == null ) { |
|
101 |
where = new StringBuilder(); |
|
102 |
} else { |
|
103 |
where.append(" AND "); |
|
104 |
} |
|
105 |
where.append("UPPER(F_TABLE_SCHEMA) = '"); |
|
106 |
where.append(schema.toUpperCase()); |
|
107 |
where.append("'"); |
|
108 |
} |
|
109 |
if( !StringUtils.isEmpty(table) ) { |
|
110 |
if( where == null ) { |
|
111 |
where = new StringBuilder(); |
|
112 |
} else { |
|
113 |
where.append(" AND "); |
|
114 |
} |
|
115 |
where.append("UPPER(F_TABLE_NAME) = '"); |
|
116 |
where.append(table.toUpperCase()); |
|
117 |
where.append("'"); |
|
118 |
} |
|
119 |
String sql = "SELECT F_GEOMETRY_COLUMN, GEOMETRY_TYPE, COORD_DIMENSION, SRID, TYPE FROM GEOMETRY_COLUMNS WHERE " + where; |
|
120 |
Statement st = this.getConnection().createStatement(); |
|
121 |
ResultSet rs = JDBCUtils.executeQuery(st,sql); |
|
122 |
while( rs.next() ) { |
|
123 |
geometry_column.put( |
|
124 |
rs.getString("F_GEOMETRY_COLUMN"), |
|
125 |
new GeometryColumnInfo( |
|
126 |
rs.getString("F_GEOMETRY_COLUMN"), |
|
127 |
rs.getInt("GEOMETRY_TYPE"), |
|
128 |
rs.getString("TYPE"), |
|
129 |
rs.getInt("COORD_DIMENSION"), |
|
130 |
rs.getInt("SRID") |
|
131 |
) |
|
132 |
); |
|
133 |
} |
|
134 |
} catch (SQLException ex) { |
|
135 |
logger.warn("Can't read metadata from table '"+table+"'.",ex); |
|
136 |
} |
|
137 |
super.fetch(featureType, conn, dbname, schema, table, pks, defaultGeometryColumn, crs); |
|
138 |
} |
|
139 |
|
|
140 |
@Override |
|
141 |
protected void fetchGeometryTypeAndSRS( |
|
142 |
EditableFeatureAttributeDescriptor attr, |
|
143 |
ResultSetMetaData rsMetadata, |
|
144 |
int colIndex |
|
145 |
) { |
|
146 |
try { |
|
147 |
if( attr.getType()==DataTypes.GEOMETRY ) { |
|
148 |
GeometryColumnInfo column_info = this.geometry_column.get(attr.getName()); |
|
149 |
String type = "GEOMETRY"; |
|
150 |
if( column_info!=null ) { |
|
151 |
// H2GIS solo soporte 2D y 3D no soporta Ms |
|
152 |
if( column_info.dimensions==3 ) { |
|
153 |
type = column_info.geometryTypeName+"Z"; |
|
154 |
} else { |
|
155 |
type = column_info.geometryTypeName; |
|
156 |
} |
|
157 |
SRSSolver solver = this.helper.getSRSSolver(); |
|
158 |
attr.setSRS( |
|
159 |
solver.getProjection(getConnection(), column_info.srid) |
|
160 |
); |
|
161 |
} |
|
162 |
GeometryType gt = getGeometryTypeFromMdbType(type); |
|
163 |
if( gt != null ) { |
|
164 |
attr.setGeometryType(gt); |
|
165 |
} |
|
166 |
} |
|
167 |
} catch(Exception ex) { |
|
168 |
throw new RuntimeException("Can't fetch geometry type and SRS.", ex); |
|
169 |
} |
|
170 |
} |
|
171 |
|
|
172 |
private GeometryType getGeometryTypeFromMdbType(String typeName) { |
|
173 |
if( h2spatialGeometryTypes==null ) { |
|
174 |
// |
|
175 |
// https://github.com/orbisgis/h2gis/wiki/1.-Spatial-data#geometry-columns-view |
|
176 |
// |
|
177 |
GeometryManager manager = GeometryLocator.getGeometryManager(); |
|
178 |
h2spatialGeometryTypes = new HashMap<>(); |
|
179 |
h2spatialGeometryTypes.put("POINT", getGT(manager, Geometry.TYPES.POINT,Geometry.SUBTYPES.GEOM2D)); |
|
180 |
h2spatialGeometryTypes.put("POINTZ", getGT(manager, Geometry.TYPES.POINT,Geometry.SUBTYPES.GEOM3D)); |
|
181 |
|
|
182 |
h2spatialGeometryTypes.put("LINESTRING", getGT(manager, Geometry.TYPES.LINE,Geometry.SUBTYPES.GEOM2D)); |
|
183 |
h2spatialGeometryTypes.put("LINESTRINGZ", getGT(manager, Geometry.TYPES.LINE,Geometry.SUBTYPES.GEOM3D)); |
|
184 |
|
|
185 |
h2spatialGeometryTypes.put("POLYGON", getGT(manager, Geometry.TYPES.POLYGON,Geometry.SUBTYPES.GEOM2D)); |
|
186 |
h2spatialGeometryTypes.put("POLYGONZ", getGT(manager, Geometry.TYPES.POLYGON,Geometry.SUBTYPES.GEOM3D)); |
|
187 |
|
|
188 |
h2spatialGeometryTypes.put("MULTIPOINT", getGT(manager, Geometry.TYPES.MULTIPOINT,Geometry.SUBTYPES.GEOM2D)); |
|
189 |
h2spatialGeometryTypes.put("MULTIPOINTZ", getGT(manager, Geometry.TYPES.MULTIPOINT,Geometry.SUBTYPES.GEOM3D)); |
|
190 |
|
|
191 |
h2spatialGeometryTypes.put("MULTILINESTRING", getGT(manager, Geometry.TYPES.MULTILINE,Geometry.SUBTYPES.GEOM2D)); |
|
192 |
h2spatialGeometryTypes.put("MULTILINESTRINGZ", getGT(manager, Geometry.TYPES.MULTILINE,Geometry.SUBTYPES.GEOM3D)); |
|
193 |
|
|
194 |
h2spatialGeometryTypes.put("MULTIPOLYGON", getGT(manager, Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM2D)); |
|
195 |
h2spatialGeometryTypes.put("MULTIPOLYGONZ", getGT(manager, Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM3D)); |
|
196 |
|
|
197 |
h2spatialGeometryTypes.put("GEOMETRY", getGT(manager, Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM2D)); |
|
198 |
h2spatialGeometryTypes.put("GEOMETRYZ", getGT(manager, Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM3D)); |
|
199 |
|
|
200 |
h2spatialGeometryTypes.put("GEOMCOLLECTION", getGT(manager, Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM2D)); |
|
201 |
h2spatialGeometryTypes.put("GEOMCOLLECTIONZ", getGT(manager, Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM3D)); |
|
202 |
} |
|
203 |
return h2spatialGeometryTypes.get(typeName); |
|
204 |
} |
|
205 |
|
|
206 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/java/org/gvsig/fmap/dal/store/mdb/operations/MdbOperationsFactory.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.fmap.dal.store.mdb.operations; |
|
3 |
|
|
4 |
import java.util.List; |
|
5 |
import org.cresques.cts.IProjection; |
|
6 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
7 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
8 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.AppendOperation; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureTypeOperation; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.ListTablesOperation; |
|
13 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.OperationsFactoryBase; |
|
14 |
|
|
15 |
|
|
16 |
public class MdbOperationsFactory extends OperationsFactoryBase { |
|
17 |
|
|
18 |
public MdbOperationsFactory(JDBCHelper helper) { |
|
19 |
super(helper); |
|
20 |
} |
|
21 |
|
|
22 |
@Override |
|
23 |
public FetchFeatureTypeOperation createFetchFeatureType(EditableFeatureType type, String database, String schema, String table, List<String> primaryKeys, String defaultGeometryField, IProjection crs) { |
|
24 |
return new MdbFetchFeatureTypeOperation( |
|
25 |
helper, type, database, schema, table, primaryKeys, |
|
26 |
defaultGeometryField, crs |
|
27 |
); |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
public ListTablesOperation createListTables(int mode, JDBCStoreParameters baseParameters, boolean informationTables) { |
|
32 |
return new MdbListTablesOperation(helper, mode, baseParameters, informationTables); |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
36 |
public AppendOperation createAppend(String database, String schema, String table, FeatureType type) { |
|
37 |
return new MdbAppendOperation(helper, database, schema, table, type); |
|
38 |
} |
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/java/org/gvsig/fmap/dal/store/mdb/MdbConnectionParameters.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.fmap.dal.store.mdb; |
|
3 |
|
|
4 |
import java.util.Properties; |
|
5 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
6 |
import org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters; |
|
7 |
|
|
8 |
public interface MdbConnectionParameters extends JDBCConnectionParameters, FilesystemStoreParameters { |
|
9 |
|
|
10 |
public Properties getProperties(); |
|
11 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/java/org/gvsig/fmap/dal/store/mdb/MdbConnectionParametersHelper.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.store.mdb; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.util.Properties; |
|
5 |
import org.apache.commons.io.FilenameUtils; |
|
6 |
import org.apache.commons.lang3.StringUtils; |
|
7 |
import org.gvsig.fmap.dal.DataParameters; |
|
8 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
9 |
import org.gvsig.fmap.dal.resource.db.DBParameters; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters; |
|
11 |
|
|
12 |
public class MdbConnectionParametersHelper { |
|
13 |
|
|
14 |
private final JDBCConnectionParameters parameters; |
|
15 |
|
|
16 |
private static final String DATABASE_FILE = "database_file"; |
|
17 |
|
|
18 |
public MdbConnectionParametersHelper(JDBCConnectionParameters parameters) { |
|
19 |
this.parameters = parameters; |
|
20 |
} |
|
21 |
|
|
22 |
public String getUrl() { |
|
23 |
String url = (String) this.getDynValue(JDBCConnectionParameters.URL_PARAMTER_NAME); |
|
24 |
if( StringUtils.isEmpty(url) ) { |
|
25 |
url = MdbHelper.getConnectionURL((MdbConnectionParameters) this.parameters); |
|
26 |
this.setDynValue(JDBCConnectionParameters.URL_PARAMTER_NAME, url); |
|
27 |
} |
|
28 |
return url; |
|
29 |
} |
|
30 |
|
|
31 |
public void validate() throws ValidateDataParametersException { |
|
32 |
if( this.getDynValue(JDBCConnectionParameters.JDBC_DRIVER_CLASS_PARAMTER_NAME) == null ) { |
|
33 |
this.setDynValue( |
|
34 |
JDBCConnectionParameters.JDBC_DRIVER_CLASS_PARAMTER_NAME, |
|
35 |
MdbHelper.MdbJDBCDriver |
|
36 |
); |
|
37 |
} |
|
38 |
if( getFile() == null ) { |
|
39 |
if( this.getDynValue(JDBCConnectionParameters.DBNAME_PARAMTER_NAME) == null ) { |
|
40 |
throw new ValidateDataParametersException(); |
|
41 |
} else { |
|
42 |
setFile(new File((String) this.getDynValue(JDBCConnectionParameters.DBNAME_PARAMTER_NAME))); |
|
43 |
} |
|
44 |
} else { |
|
45 |
String dbName = (String) this.getDynValue(JDBCConnectionParameters.DBNAME_PARAMTER_NAME); |
|
46 |
if( StringUtils.isEmpty(dbName) ) { |
|
47 |
dbName = getDbNameFromFile(getFile()); |
|
48 |
this.setDynValue( |
|
49 |
JDBCConnectionParameters.DBNAME_PARAMTER_NAME, |
|
50 |
dbName.toUpperCase() |
|
51 |
); |
|
52 |
} |
|
53 |
} |
|
54 |
if( this.getDynValue(JDBCConnectionParameters.URL_PARAMTER_NAME) == null ) { |
|
55 |
String url = MdbHelper.getConnectionURL((MdbConnectionParameters) this.parameters); |
|
56 |
this.setDynValue(JDBCConnectionParameters.URL_PARAMTER_NAME, url); |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
60 |
private Object getDynValue(String name) { |
|
61 |
return ((DataParameters) this.parameters).getDynValue(name); |
|
62 |
} |
|
63 |
|
|
64 |
private void setDynValue(String name, Object value) { |
|
65 |
((DataParameters) this.parameters).setDynValue(name, value); |
|
66 |
} |
|
67 |
|
|
68 |
public File getFile() { |
|
69 |
File f = (File) this.getDynValue(DATABASE_FILE); |
|
70 |
if( this.getDynValue(DBParameters.DBNAME_PARAMTER_NAME) == null |
|
71 |
&& f != null ) { |
|
72 |
String dbname = getDbNameFromFile(f); |
|
73 |
this.setDynValue(DBParameters.DBNAME_PARAMTER_NAME, dbname); |
|
74 |
} |
|
75 |
return f; |
|
76 |
} |
|
77 |
|
|
78 |
public void setFile(File database) { |
|
79 |
this.setDynValue(DATABASE_FILE, database); |
|
80 |
if( this.getDynValue(DBParameters.DBNAME_PARAMTER_NAME) == null |
|
81 |
&& database != null ) { |
|
82 |
String dbname = getDbNameFromFile(database); |
|
83 |
this.setDynValue(DBParameters.DBNAME_PARAMTER_NAME, dbname); |
|
84 |
} |
|
85 |
} |
|
86 |
|
|
87 |
public Properties getProperties() { |
|
88 |
Properties props = new Properties(); |
|
89 |
return props; |
|
90 |
} |
|
91 |
|
|
92 |
private String getDbNameFromFile(File f) { |
|
93 |
String fname = f.getName(); |
|
94 |
if( fname.toLowerCase().endsWith(".mv.db") ) { |
|
95 |
fname = fname.substring(0, fname.length()-6); |
|
96 |
} else { |
|
97 |
fname = FilenameUtils.getBaseName(fname); |
|
98 |
} |
|
99 |
return fname; |
|
100 |
} |
|
101 |
|
|
102 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/java/org/gvsig/fmap/dal/store/mdb/SpatialFunctions.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.fmap.dal.store.mdb; |
|
3 |
|
|
4 |
import com.vividsolutions.jts.geom.Geometry; |
|
5 |
import com.vividsolutions.jts.io.WKBReader; |
|
6 |
import java.sql.Blob; |
|
7 |
import java.sql.Connection; |
|
8 |
import java.sql.SQLException; |
|
9 |
import net.ucanaccess.converters.TypesMap.AccessType; |
|
10 |
import net.ucanaccess.ext.FunctionType; |
|
11 |
import net.ucanaccess.jdbc.UcanaccessConnection; |
|
12 |
import org.gvsig.fmap.dal.ExpressionBuilder; |
|
13 |
|
|
14 |
|
|
15 |
public class SpatialFunctions { |
|
16 |
|
|
17 |
|
|
18 |
public static void selfRegister(Connection conn) throws SQLException { |
|
19 |
UcanaccessConnection uc=(UcanaccessConnection)conn; |
|
20 |
uc.addFunctions(SpatialFunctions.class); |
|
21 |
} |
|
22 |
|
|
23 |
private static Geometry toGeometry(Blob blob) { |
|
24 |
try { |
|
25 |
WKBReader reader = new WKBReader(); |
|
26 |
Geometry geom = reader.read(blob.getBytes(1, (int) blob.length())); |
|
27 |
return geom; |
|
28 |
} catch (Exception ex) { |
|
29 |
return null; |
|
30 |
} |
|
31 |
} |
|
32 |
|
|
33 |
@FunctionType(functionName="ST_AsText", argumentTypes={AccessType.OLE},returnType=AccessType.TEXT) |
|
34 |
public static String ST_AsText(Blob arg) { |
|
35 |
Geometry geom = toGeometry(arg); |
|
36 |
if( geom == null ) { |
|
37 |
return null; |
|
38 |
} |
|
39 |
return geom.toText(); |
|
40 |
} |
|
41 |
|
|
42 |
@FunctionType(functionName="ST_AsBinary", argumentTypes={AccessType.OLE},returnType=AccessType.OLE) |
|
43 |
public static Blob ST_AsBinary(Blob arg) { |
|
44 |
return arg; |
|
45 |
} |
|
46 |
|
|
47 |
@FunctionType(functionName="ST_Envelope", argumentTypes={AccessType.OLE},returnType=AccessType.OLE) |
|
48 |
public static Blob ST_Envelope(Blob arg) { |
|
49 |
Geometry geom = toGeometry(arg); |
|
50 |
if( geom == null ) { |
|
51 |
return null; |
|
52 |
} |
|
53 |
Geometry env = geom.getEnvelope(); |
|
54 |
|
|
55 |
return arg; |
|
56 |
} |
|
57 |
|
|
58 |
@FunctionType(functionName="ST_Touches", argumentTypes={AccessType.OLE,AccessType.OLE},returnType=AccessType.YESNO) |
|
59 |
public static boolean ST_Touches(Blob arg1, Blob arg2) { |
|
60 |
Geometry geom1 = toGeometry(arg1); |
|
61 |
if( geom1 == null ) { |
|
62 |
return false; |
|
63 |
} |
|
64 |
Geometry geom2 = toGeometry(arg2); |
|
65 |
if( geom2 == null ) { |
|
66 |
return false; |
|
67 |
} |
|
68 |
return geom1.touches(geom2); |
|
69 |
} |
|
70 |
|
|
71 |
/* |
|
72 |
public ExpressionBuilder.Function ST_SRID(ExpressionBuilder.Value geom); |
|
73 |
|
|
74 |
public ExpressionBuilder.Function ST_AsEWKB(ExpressionBuilder.Value geom); |
|
75 |
|
|
76 |
public ExpressionBuilder.Function ST_Envelope(ExpressionBuilder.Value geom); |
|
77 |
|
|
78 |
public ExpressionBuilder.Function ST_GeomFromText(ExpressionBuilder.Value geom, ExpressionBuilder.Value crs); |
|
79 |
|
|
80 |
public ExpressionBuilder.Function ST_GeomFromWKB(ExpressionBuilder.Value geom, ExpressionBuilder.Value crs); |
|
81 |
|
|
82 |
public ExpressionBuilder.Function ST_GeomFromEWKB(ExpressionBuilder.Value geom, ExpressionBuilder.Value crs); |
|
83 |
|
|
84 |
public ExpressionBuilder.Function ST_Simplify(ExpressionBuilder.Value geom, ExpressionBuilder.Value tolerance); |
|
85 |
|
|
86 |
public ExpressionBuilder.Function ST_Equals(ExpressionBuilder.Value geom1, ExpressionBuilder.Value geom2); |
|
87 |
|
|
88 |
public ExpressionBuilder.Function ST_Intersects(ExpressionBuilder.Value geom1, ExpressionBuilder.Value geom2); |
|
89 |
|
|
90 |
public ExpressionBuilder.Function ST_Contains(ExpressionBuilder.Value geom1, ExpressionBuilder.Value geom2); |
|
91 |
|
|
92 |
public ExpressionBuilder.Function ST_Disjoint(ExpressionBuilder.Value geom1, ExpressionBuilder.Value geom2); |
|
93 |
|
|
94 |
public ExpressionBuilder.Function ST_Crosses(ExpressionBuilder.Value geom1, ExpressionBuilder.Value geom2); |
|
95 |
|
|
96 |
public ExpressionBuilder.Function ST_IsClosed(ExpressionBuilder.Value geom1); |
|
97 |
|
|
98 |
public ExpressionBuilder.Function ST_Overlaps(ExpressionBuilder.Value geom1, ExpressionBuilder.Value geom2); |
|
99 |
|
|
100 |
public ExpressionBuilder.Function ST_Within(ExpressionBuilder.Value geom1, ExpressionBuilder.Value geom2); |
|
101 |
*/ |
|
102 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/java/org/gvsig/fmap/dal/store/mdb/MdbExplorerParameters.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
/** |
|
23 |
* |
|
24 |
*/ |
|
25 |
package org.gvsig.fmap.dal.store.mdb; |
|
26 |
|
|
27 |
import java.io.File; |
|
28 |
import java.util.Properties; |
|
29 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
30 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
|
31 |
|
|
32 |
public class MdbExplorerParameters extends |
|
33 |
JDBCServerExplorerParameters |
|
34 |
implements |
|
35 |
MdbConnectionParameters |
|
36 |
{ |
|
37 |
|
|
38 |
private final MdbConnectionParametersHelper helper; |
|
39 |
|
|
40 |
public MdbExplorerParameters() { |
|
41 |
super( |
|
42 |
MdbLibrary.NAME + "ServerExplorerParameters", |
|
43 |
MdbLibrary.NAME |
|
44 |
); |
|
45 |
this.helper = new MdbConnectionParametersHelper(this); |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public String getUrl() { |
|
50 |
return this.helper.getUrl(); |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public void validate() throws ValidateDataParametersException { |
|
55 |
this.helper.validate(); |
|
56 |
super.validate(); |
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
public Properties getProperties() { |
|
61 |
return this.helper.getProperties(); |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
public File getFile() { |
|
66 |
return this.helper.getFile(); |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public void setFile(File database) { |
|
71 |
this.helper.setFile(database); |
|
72 |
} |
|
73 |
|
|
74 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/main/java/org/gvsig/fmap/dal/store/mdb/MdbLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.fmap.dal.store.mdb; |
|
23 |
|
|
24 |
import org.gvsig.fmap.dal.DALLibrary; |
|
25 |
import org.gvsig.fmap.dal.DALLocator; |
|
26 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
27 |
import org.gvsig.fmap.dal.store.db.DBHelper; |
|
28 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCLibrary; |
|
29 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCStoreProviderBase; |
|
30 |
import org.gvsig.metadata.exceptions.MetadataException; |
|
31 |
import org.gvsig.tools.library.AbstractLibrary; |
|
32 |
import org.gvsig.tools.library.LibraryException; |
|
33 |
|
|
34 |
public class MdbLibrary extends AbstractLibrary { |
|
35 |
|
|
36 |
public static final String NAME = "Mdb"; |
|
37 |
|
|
38 |
@Override |
|
39 |
public void doRegistration() { |
|
40 |
registerAsServiceOf(DALLibrary.class); |
|
41 |
require(JDBCLibrary.class); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
protected void doInitialize() throws LibraryException { |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
protected void doPostInitialize() throws LibraryException { |
|
50 |
LibraryException ex = null; |
|
51 |
|
|
52 |
DataManagerProviderServices dataman = |
|
53 |
(DataManagerProviderServices) DALLocator.getDataManager(); |
|
54 |
|
|
55 |
try { |
|
56 |
Class.forName(MdbHelper.MdbJDBCDriver); |
|
57 |
} catch(Throwable th) { |
|
58 |
MdbHelper.logger.warn("Can't load Mdb JDBC Driver.",th); |
|
59 |
} |
Also available in: Unified diff