Revision 107
tags/org.gvsig.mysql-2.4.16/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
4 |
|
|
5 |
<modelVersion>4.0.0</modelVersion> |
|
6 |
<artifactId>org.gvsig.mysql</artifactId> |
|
7 |
<version>2.4.16</version> |
|
8 |
<packaging>pom</packaging> |
|
9 |
<name>${project.artifactId}</name> |
|
10 |
<description>MySQL support for DAL and gvSIG</description> |
|
11 |
<parent> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.desktop</artifactId> |
|
14 |
<version>2.0.209</version> |
|
15 |
</parent> |
|
16 |
|
|
17 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-mysql</url> |
|
18 |
<scm> |
|
19 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-mysql/tags/org.gvsig.mysql-2.4.16</connection> |
|
20 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-mysql/tags/org.gvsig.mysql-2.4.16</developerConnection> |
|
21 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-mysql/repository/show/tags/org.gvsig.mysql-2.4.16</url> |
|
22 |
</scm> |
|
23 |
|
|
24 |
<repositories> |
|
25 |
<repository> |
|
26 |
<id>gvsig-public-http-repository</id> |
|
27 |
<name>gvSIG maven public HTTP repository</name> |
|
28 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
29 |
<releases> |
|
30 |
<enabled>true</enabled> |
|
31 |
<updatePolicy>daily</updatePolicy> |
|
32 |
<checksumPolicy>warn</checksumPolicy> |
|
33 |
</releases> |
|
34 |
<snapshots> |
|
35 |
<enabled>true</enabled> |
|
36 |
<updatePolicy>daily</updatePolicy> |
|
37 |
<checksumPolicy>warn</checksumPolicy> |
|
38 |
</snapshots> |
|
39 |
</repository> |
|
40 |
</repositories> |
|
41 |
|
|
42 |
|
|
43 |
<build> |
|
44 |
<plugins> |
|
45 |
<plugin> |
|
46 |
<groupId>org.apache.maven.plugins</groupId> |
|
47 |
<artifactId>maven-release-plugin</artifactId> |
|
48 |
<configuration> |
|
49 |
<tagBase>https://devel.gvsig.org/svn/gvsig-mysql/tags/</tagBase> |
|
50 |
<goals>deploy</goals> |
|
51 |
</configuration> |
|
52 |
</plugin> |
|
53 |
</plugins> |
|
54 |
</build> |
|
55 |
|
|
56 |
|
|
57 |
<dependencyManagement> |
|
58 |
<dependencies> |
|
59 |
<dependency> |
|
60 |
<groupId>org.gvsig</groupId> |
|
61 |
<artifactId>org.gvsig.mysql.provider</artifactId> |
|
62 |
<version>2.4.16</version> |
|
63 |
</dependency> |
|
64 |
<dependency> |
|
65 |
<groupId>org.gvsig</groupId> |
|
66 |
<artifactId>org.gvsig.mysql.app.mainplugin</artifactId> |
|
67 |
<version>2.4.16</version> |
|
68 |
</dependency> |
|
69 |
<dependency> |
|
70 |
<groupId>mysql</groupId> |
|
71 |
<artifactId>mysql-connector-java</artifactId> |
|
72 |
<version>6.0.6</version> |
|
73 |
</dependency> |
|
74 |
|
|
75 |
|
|
76 |
</dependencies> |
|
77 |
</dependencyManagement> |
|
78 |
|
|
79 |
<modules> |
|
80 |
<module>org.gvsig.mysql.app</module> |
|
81 |
<module>org.gvsig.mysql.provider</module> |
|
82 |
</modules> |
|
83 |
|
|
84 |
|
|
85 |
</project> |
tags/org.gvsig.mysql-2.4.16/org.gvsig.mysql.provider/src/test/java/org/gvsig/mysql/dal/MySQLSQLBuilderTest.java | ||
---|---|---|
1 |
package org.gvsig.mysql.dal; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
import org.apache.commons.lang3.ArrayUtils; |
|
6 |
import org.cresques.cts.IProjection; |
|
7 |
import org.gvsig.fmap.crs.CRSFactory; |
|
8 |
import org.gvsig.fmap.dal.DALLocator; |
|
9 |
import org.gvsig.fmap.dal.ExpressionBuilder; |
|
10 |
import org.gvsig.fmap.dal.ExpressionBuilder.Parameter; |
|
11 |
import org.gvsig.fmap.dal.ExpressionBuilder.Variable; |
|
12 |
import org.gvsig.fmap.dal.SQLBuilder; |
|
13 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
14 |
import org.gvsig.fmap.dal.store.db.DBHelper; |
|
15 |
import org.gvsig.fmap.geom.DataTypes; |
|
16 |
import org.gvsig.fmap.geom.Geometry; |
|
17 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
18 |
import org.gvsig.fmap.geom.GeometryManager; |
|
19 |
import org.gvsig.fmap.geom.primitive.Polygon; |
|
20 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
|
21 |
|
|
22 |
public class MySQLSQLBuilderTest extends AbstractLibraryAutoInitTestCase { |
|
23 |
|
|
24 |
private MySQLHelper helper; |
|
25 |
|
|
26 |
@Override |
|
27 |
protected void doSetUp() throws Exception { |
|
28 |
DataManagerProviderServices dataman = |
|
29 |
(DataManagerProviderServices) DALLocator.getDataManager(); |
|
30 |
|
|
31 |
DBHelper.registerParametersDefinition( |
|
32 |
MySQLLibrary.NAME + "StoreParameters", |
|
33 |
MySQLStoreParameters.class, |
|
34 |
dataman.getResourceAsStream(this, MySQLLibrary.NAME + "Parameters.xml") |
|
35 |
); |
|
36 |
|
|
37 |
MySQLStoreParameters params = new MySQLStoreParameters(); |
|
38 |
params.setDBName("test.sqlite"); |
|
39 |
params.setTable("test1"); |
|
40 |
helper = new MySQLHelper(params); |
|
41 |
} |
|
42 |
|
|
43 |
List<String> getVariableNames(ExpressionBuilder builder) { |
|
44 |
List<String> vars = new ArrayList<>(); |
|
45 |
for (Variable var : builder.getVariables()) { |
|
46 |
vars.add(var.getName()); |
|
47 |
} |
|
48 |
return vars; |
|
49 |
} |
|
50 |
|
|
51 |
List<String> getParameterNames(ExpressionBuilder builder) { |
|
52 |
List<String> params = new ArrayList<>(); |
|
53 |
for (Parameter param : builder.getParameters()) { |
|
54 |
String s; |
|
55 |
switch(param.getType()) { |
|
56 |
case Constant: |
|
57 |
Object value = param.getValue(); |
|
58 |
if( value==null ) { |
|
59 |
s = "null"; |
|
60 |
} else if( value instanceof String ) { |
|
61 |
s = "'" + (String)value + "'"; |
|
62 |
} else { |
|
63 |
s = value.toString(); |
|
64 |
} |
|
65 |
break; |
|
66 |
case Geometry: |
|
67 |
case Variable: |
|
68 |
default: |
|
69 |
s = "\"" + param.getName() + "\""; |
|
70 |
} |
|
71 |
params.add(s); |
|
72 |
} |
|
73 |
return params; |
|
74 |
} |
|
75 |
|
|
76 |
public SQLBuilder createSQLBuilder() { |
|
77 |
return new MySQLSQLBuilder(helper); |
|
78 |
} |
|
79 |
|
|
80 |
public void testCalulateEnvelope() throws Exception { |
|
81 |
GeometryManager geometryManager = GeometryLocator.getGeometryManager(); |
|
82 |
IProjection proj = CRSFactory.getCRS("EPSG:4326"); |
|
83 |
|
|
84 |
Polygon limit = geometryManager.createPolygon(Geometry.SUBTYPES.GEOM2D); |
|
85 |
limit.addVertex(0, 0); |
|
86 |
limit.addVertex(0, 100); |
|
87 |
limit.addVertex(100, 100); |
|
88 |
limit.addVertex(100, 0); |
|
89 |
limit.addVertex(0, 0); |
|
90 |
|
|
91 |
SQLBuilder builder = createSQLBuilder(); |
|
92 |
|
|
93 |
builder.select().column().value( |
|
94 |
builder.getAsGeometry( |
|
95 |
builder.ST_ExtentAggregate( |
|
96 |
builder.column("the_geom") |
|
97 |
) |
|
98 |
) |
|
99 |
).as("envelope"); |
|
100 |
builder.select().from().table().database("master").schema("dbo").name("test1"); |
|
101 |
builder.select().where().set( |
|
102 |
builder.ST_Intersects( |
|
103 |
builder.ST_Envelope( |
|
104 |
builder.column("the_geom") |
|
105 |
), |
|
106 |
builder.geometry(limit, proj) |
|
107 |
) |
|
108 |
); |
|
109 |
builder.select().where().and( |
|
110 |
builder.custom("x = 27").add( builder.variable("x") ) |
|
111 |
); |
|
112 |
|
|
113 |
System.out.println("# Test:: testCalulateEnvelope"); |
|
114 |
System.out.println("# SQL:: " + builder.toString()); |
|
115 |
System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder))); |
|
116 |
System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder))); |
|
117 |
|
|
118 |
//# Test:: testCalulateEnvelope |
|
119 |
//# SQL:: SELECT ST_AsBinary(Extent("the_geom")) AS "envelope" FROM "test1" WHERE ST_Intersects((ST_Envelope("the_geom")), (ST_GeomFromWKB((x'000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000'), (4326)))) AND x = 27 |
|
120 |
//# Variables:: [the_geom, x] |
|
121 |
//# Parametros:: [] |
|
122 |
assertEquals( |
|
123 |
"SELECT ST_AsBinary(Extent(\"the_geom\")) AS \"envelope\" FROM \"test1\" WHERE ST_Intersects((ST_Envelope(\"the_geom\")), (ST_GeomFromWKB((x'000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000'), (4326)))) AND x = 27", |
|
124 |
builder.toString() |
|
125 |
); |
|
126 |
assertEquals( |
|
127 |
"[the_geom, x]", |
|
128 |
ArrayUtils.toString(getVariableNames(builder)) |
|
129 |
); |
|
130 |
assertEquals( |
|
131 |
"[]", |
|
132 |
ArrayUtils.toString(getParameterNames(builder)) |
|
133 |
); |
|
134 |
} |
|
135 |
|
|
136 |
public void testCount() throws Exception { |
|
137 |
SQLBuilder builder = createSQLBuilder(); |
|
138 |
|
|
139 |
builder.select().column().value(builder.count().all()); |
|
140 |
builder.select().from().table().database("master").schema("dbo").name("test1"); |
|
141 |
builder.select().from().subquery(null); |
|
142 |
builder.select().where().set( builder.custom("pp = 200").add(builder.variable("pp"))); |
|
143 |
|
|
144 |
System.out.println("# Test:: testCount"); |
|
145 |
System.out.println("# SQL:: " + builder.toString()); |
|
146 |
System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder))); |
|
147 |
System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder))); |
|
148 |
|
|
149 |
//# Test:: testCount |
|
150 |
//# SQL:: SELECT COUNT(*) FROM "test1" WHERE pp = 200 |
|
151 |
//# Variables:: [pp] |
|
152 |
//# Parametros:: [] |
|
153 |
|
|
154 |
assertEquals( |
|
155 |
"SELECT COUNT(*) FROM \"test1\" WHERE pp = 200", |
|
156 |
builder.toString() |
|
157 |
); |
|
158 |
assertEquals( |
|
159 |
"[pp]", |
|
160 |
ArrayUtils.toString(getVariableNames(builder)) |
|
161 |
); |
|
162 |
assertEquals( |
|
163 |
"[]", |
|
164 |
ArrayUtils.toString(getParameterNames(builder)) |
|
165 |
); |
|
166 |
} |
|
167 |
|
|
168 |
public void testUpdateStatistics() throws Exception { |
|
169 |
SQLBuilder builder = createSQLBuilder(); |
|
170 |
|
|
171 |
builder.update_table_statistics().table().database("master").schema("dbo").name("test1"); |
|
172 |
|
|
173 |
System.out.println("# Test:: testUpdateStatistics"); |
|
174 |
System.out.println("# SQL:: " + builder.toString()); |
|
175 |
System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder))); |
|
176 |
System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder))); |
|
177 |
|
|
178 |
//# Test:: testUpdateStatistics |
|
179 |
//# SQL:: SELECT UpdateLayerStatistics("test1") |
|
180 |
//# Variables:: [] |
|
181 |
//# Parametros:: [] |
|
182 |
|
|
183 |
assertEquals( |
|
184 |
"SELECT UpdateLayerStatistics(\"test1\")", |
|
185 |
builder.toString() |
|
186 |
); |
|
187 |
assertEquals( |
|
188 |
"[]", |
|
189 |
ArrayUtils.toString(getVariableNames(builder)) |
|
190 |
); |
|
191 |
assertEquals( |
|
192 |
"[]", |
|
193 |
ArrayUtils.toString(getParameterNames(builder)) |
|
194 |
); |
|
195 |
} |
|
196 |
|
|
197 |
public void testCreateTable() throws Exception { |
|
198 |
SQLBuilder builder = createSQLBuilder(); |
|
199 |
|
|
200 |
builder.create_table().table().database("master").schema("dbo").name("test1"); |
|
201 |
builder.create_table().add_column( |
|
202 |
"name", |
|
203 |
DataTypes.STRING, |
|
204 |
45, |
|
205 |
0, |
|
206 |
false, |
|
207 |
false, |
|
208 |
true, |
|
209 |
false, |
|
210 |
null |
|
211 |
); |
|
212 |
builder.create_table().add_column( |
|
213 |
"id", |
|
214 |
DataTypes.INT, |
|
215 |
0, |
|
216 |
0, |
|
217 |
true, |
|
218 |
false, |
|
219 |
false, |
|
220 |
true, |
|
221 |
0 |
|
222 |
); |
|
223 |
builder.create_table().add_column( |
|
224 |
"geom", |
|
225 |
DataTypes.GEOMETRY, |
|
226 |
0, |
|
227 |
0, |
|
228 |
false, |
|
229 |
false, |
|
230 |
true, |
|
231 |
false, |
|
232 |
null |
|
233 |
); |
|
234 |
|
|
235 |
System.out.println("# Test:: testCreateTable"); |
|
236 |
System.out.println("# SQL:: " + builder.toString()); |
|
237 |
System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder))); |
|
238 |
System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder))); |
|
239 |
|
|
240 |
//# Test:: testCreateTable |
|
241 |
//# SQL:: CREATE TABLE "test1" ("name" TEXT DEFAULT NULL NULL, "id" INTEGER PRIMARY KEY AUTOINCREMENT DEFAULT '0' NOT NULL ); SELECT AddGeometryColumn("test1" , "geom" , -1 , 'GEOMETRY' , 'XYZ', 1) |
|
242 |
//# Variables:: [] |
|
243 |
//# Parametros:: [] |
|
244 |
|
|
245 |
assertEquals( |
|
246 |
"CREATE TABLE \"test1\" (\"name\" TEXT DEFAULT NULL NULL, \"id\" INTEGER PRIMARY KEY AUTOINCREMENT DEFAULT '0' NOT NULL ); SELECT AddGeometryColumn(\"test1\" , \"geom\" , -1 , 'GEOMETRY' , 'XYZ', 1)", |
|
247 |
builder.toString() |
|
248 |
); |
|
249 |
assertEquals( |
|
250 |
"[]", |
|
251 |
ArrayUtils.toString(getVariableNames(builder)) |
|
252 |
); |
|
253 |
assertEquals( |
|
254 |
"[]", |
|
255 |
ArrayUtils.toString(getParameterNames(builder)) |
|
256 |
); |
|
257 |
} |
|
258 |
|
|
259 |
public void testDropTable() throws Exception { |
|
260 |
SQLBuilder builder = createSQLBuilder(); |
|
261 |
|
|
262 |
builder.drop_table().table().database("master").schema("dbo").name("test1"); |
|
263 |
|
|
264 |
System.out.println("# Test:: testDropTable"); |
|
265 |
System.out.println("# SQL:: " + builder.toString()); |
|
266 |
System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder))); |
|
267 |
System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder))); |
|
268 |
|
|
269 |
//# Test:: testDropTable |
|
270 |
//# SQL:: DROP TABLE [master].[dbo].[test1] |
|
271 |
//# Variables:: [] |
|
272 |
//# Parametros:: [] |
|
273 |
|
|
274 |
assertEquals( |
|
275 |
"DROP TABLE [master].[dbo].[test1]", |
|
276 |
builder.toString() |
|
277 |
); |
|
278 |
assertEquals( |
|
279 |
"[]", |
|
280 |
ArrayUtils.toString(getVariableNames(builder)) |
|
281 |
); |
|
282 |
assertEquals( |
|
283 |
"[]", |
|
284 |
ArrayUtils.toString(getParameterNames(builder)) |
|
285 |
); |
|
286 |
} |
|
287 |
|
|
288 |
public void testFetchFeatureProviderByReference() throws Exception { |
|
289 |
SQLBuilder builder = createSQLBuilder(); |
|
290 |
|
|
291 |
String value = "yoyo"; |
|
292 |
builder.select().column().name("name"); |
|
293 |
builder.select().column().name("id"); |
|
294 |
builder.select().column().name("geom").as_geometry(); |
|
295 |
builder.select().from().table().database("master").schema("dbo").name("test1"); |
|
296 |
builder.select().where().set( |
|
297 |
builder.eq( |
|
298 |
builder.column("name"), |
|
299 |
builder.parameter(value).as_constant() |
|
300 |
) |
|
301 |
); |
|
302 |
builder.select().limit(1); |
|
303 |
|
|
304 |
System.out.println("# Test:: testFetchFeatureProviderByReference"); |
|
305 |
System.out.println("# SQL:: " + builder.toString()); |
|
306 |
System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder))); |
|
307 |
System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder))); |
|
308 |
|
|
309 |
//# Test:: testFetchFeatureProviderByReference |
|
310 |
//# SQL:: SELECT TOP 1 [name], [id], ([geom]).STAsBinary() FROM [master].[dbo].[test1] WHERE ( ([name]) = (?) ) |
|
311 |
//# Variables:: [geom, id, name] |
|
312 |
//# Parametros:: ['yoyo'] |
|
313 |
|
|
314 |
assertEquals( |
|
315 |
"SELECT TOP 1 [name], [id], ([geom]).STAsBinary() FROM [master].[dbo].[test1] WHERE ( ([name]) = (?) )", |
|
316 |
builder.toString() |
|
317 |
); |
|
318 |
assertEquals( |
|
319 |
"[geom, id, name]", |
|
320 |
ArrayUtils.toString(getVariableNames(builder)) |
|
321 |
); |
|
322 |
assertEquals( |
|
323 |
"['yoyo']", |
|
324 |
ArrayUtils.toString(getParameterNames(builder)) |
|
325 |
); |
|
326 |
} |
|
327 |
|
|
328 |
public void testIsNull() throws Exception { |
|
329 |
SQLBuilder builder = createSQLBuilder(); |
|
330 |
|
|
331 |
builder.select().column().name("name"); |
|
332 |
builder.select().column().name("id"); |
|
333 |
builder.select().column().name("geom").as_geometry(); |
|
334 |
builder.select().from().table().database("master").schema("dbo").name("test1"); |
|
335 |
builder.select().where().set( |
|
336 |
builder.and( |
|
337 |
builder.isNull( |
|
338 |
builder.column("name") |
|
339 |
), |
|
340 |
builder.notIsNull( |
|
341 |
builder.column("id") |
|
342 |
) |
|
343 |
) |
|
344 |
); |
|
345 |
builder.select().limit(2); |
|
346 |
|
|
347 |
System.out.println("# Test:: testIsNull"); |
|
348 |
System.out.println("# SQL:: " + builder.toString()); |
|
349 |
System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder))); |
|
350 |
System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder))); |
|
351 |
|
|
352 |
//# Test:: testIsNull |
|
353 |
//# SQL:: SELECT TOP 2 [name], [id], ([geom]).STAsBinary() FROM [master].[dbo].[test1] WHERE ( ([name]) IS NULL ) AND ( ([id]) NOT IS NULL ) |
|
354 |
//# Variables:: [geom, id, name] |
|
355 |
//# Parametros:: [] |
|
356 |
|
|
357 |
assertEquals( |
|
358 |
"SELECT TOP 2 [name], [id], ([geom]).STAsBinary() FROM [master].[dbo].[test1] WHERE ( ([name]) IS NULL ) AND ( ([id]) NOT IS NULL )", |
|
359 |
builder.toString() |
|
360 |
); |
|
361 |
assertEquals( |
|
362 |
"[geom, id, name]", |
|
363 |
ArrayUtils.toString(getVariableNames(builder)) |
|
364 |
); |
|
365 |
assertEquals( |
|
366 |
"[]", |
|
367 |
ArrayUtils.toString(getParameterNames(builder)) |
|
368 |
); |
|
369 |
} |
|
370 |
|
|
371 |
public void testFetchFeatureType() throws Exception { |
|
372 |
SQLBuilder builder = createSQLBuilder(); |
|
373 |
|
|
374 |
builder.select().column().all(); |
|
375 |
builder.select().from().table().database("master").schema("dbo").name("test1"); |
|
376 |
builder.select().limit(1); |
|
377 |
|
|
378 |
System.out.println("# Test:: testFetchFeatureType"); |
|
379 |
System.out.println("# SQL:: " + builder.toString()); |
|
380 |
System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder))); |
|
381 |
System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder))); |
|
382 |
|
|
383 |
//# Test:: testFetchFeatureType |
|
384 |
//# SQL:: SELECT TOP 1 * FROM [master].[dbo].[test1] |
|
385 |
//# Variables:: [] |
|
386 |
//# Parametros:: [] |
|
387 |
|
|
388 |
assertEquals( |
|
389 |
"SELECT TOP 1 * FROM [master].[dbo].[test1]", |
|
390 |
builder.toString() |
|
391 |
); |
|
392 |
assertEquals( |
|
393 |
"[]", |
|
394 |
ArrayUtils.toString(getVariableNames(builder)) |
|
395 |
); |
|
396 |
assertEquals( |
|
397 |
"[]", |
|
398 |
ArrayUtils.toString(getParameterNames(builder)) |
|
399 |
); |
|
400 |
} |
|
401 |
|
|
402 |
public void testPerformDeletes() throws Exception { |
|
403 |
SQLBuilder builder = createSQLBuilder(); |
|
404 |
|
|
405 |
builder.delete().table().database("master").schema("dbo").name("test1"); |
|
406 |
builder.delete().where().and( |
|
407 |
builder.eq( |
|
408 |
builder.column("id1"), |
|
409 |
builder.parameter("id1").as_variable() |
|
410 |
) |
|
411 |
); |
|
412 |
builder.delete().where().and( |
|
413 |
builder.eq( |
|
414 |
builder.column("id2"), |
|
415 |
builder.parameter("id2").as_variable() |
|
416 |
) |
|
417 |
); |
|
418 |
|
|
419 |
System.out.println("# Test:: testPerformDeletes"); |
|
420 |
System.out.println("# SQL:: " + builder.toString()); |
|
421 |
System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder))); |
|
422 |
System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder))); |
|
423 |
|
|
424 |
//# Test:: testPerformDeletes |
|
425 |
//# SQL:: DELETE FROM [master].[dbo].[test1] WHERE ( ([id1]) = (?) ) AND ( ([id2]) = (?) ) |
|
426 |
//# Variables:: [id1, id2] |
|
427 |
//# Parametros:: ["id1", "id2"] |
|
428 |
|
|
429 |
assertEquals( |
|
430 |
"DELETE FROM [master].[dbo].[test1] WHERE ( ([id1]) = (?) ) AND ( ([id2]) = (?) )", |
|
431 |
builder.toString() |
|
432 |
); |
|
433 |
assertEquals( |
|
434 |
"[id1, id2]", |
|
435 |
ArrayUtils.toString(getVariableNames(builder)) |
|
436 |
); |
|
437 |
assertEquals( |
|
438 |
"[\"id1\", \"id2\"]", |
|
439 |
ArrayUtils.toString(getParameterNames(builder)) |
|
440 |
); |
|
441 |
} |
|
442 |
|
|
443 |
public void testPerformInserts1() throws Exception { |
|
444 |
IProjection proj = CRSFactory.getCRS("EPSG:4326"); |
|
445 |
|
|
446 |
SQLBuilder builder = createSQLBuilder(); |
|
447 |
|
|
448 |
builder.insert().table().database("master").schema("dbo").name("test1"); |
|
449 |
builder.insert().column().name("id").with_value(builder.parameter("id")); |
|
450 |
builder.insert().column().name("name").with_value(builder.parameter("name")); |
|
451 |
builder.insert().column().name("geom").with_value(builder.parameter("geom").as_geometry_variable().srs(builder.parameter().srs(proj))); |
|
452 |
|
|
453 |
System.out.println("# Test:: testPerformInserts1"); |
|
454 |
System.out.println("# SQL:: " + builder.toString()); |
|
455 |
System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder))); |
|
456 |
System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder))); |
|
457 |
|
|
458 |
//# Test:: testPerformInserts1 |
|
459 |
//# SQL:: INSERT INTO [master].[dbo].[test1] ( [id], [name], [geom] ) VALUES ( ?, ?, geometry::STGeomFromWKB(?, 4326) ) |
|
460 |
//# Variables:: [geom, id, name] |
|
461 |
//# Parametros:: ["id", "name", "geom"] |
|
462 |
|
|
463 |
assertEquals( |
|
464 |
"INSERT INTO [master].[dbo].[test1] ( [id], [name], [geom] ) VALUES ( ?, ?, geometry::STGeomFromWKB(?, 4326) )", |
|
465 |
builder.toString() |
|
466 |
); |
|
467 |
assertEquals( |
|
468 |
"[geom, id, name]", |
|
469 |
ArrayUtils.toString(getVariableNames(builder)) |
|
470 |
); |
|
471 |
assertEquals( |
|
472 |
"[\"id\", \"name\", \"geom\"]", |
|
473 |
ArrayUtils.toString(getParameterNames(builder)) |
|
474 |
); |
|
475 |
} |
|
476 |
|
|
477 |
public void testPerformInserts2() throws Exception { |
|
478 |
IProjection proj = CRSFactory.getCRS("EPSG:4326"); |
|
479 |
|
|
480 |
SQLBuilder builder = createSQLBuilder(); |
|
481 |
|
|
482 |
builder.insert().table().database("master").schema("dbo").name("test1"); |
|
483 |
builder.insert().column().name("id").with_value(builder.parameter("id")); |
|
484 |
builder.insert().column().name("name").with_value(builder.parameter("name")); |
|
485 |
builder.insert().column().name("geom").with_value(builder.parameter("geom").as_geometry_variable().srs(builder.parameter().srs(proj))); |
|
486 |
|
|
487 |
System.out.println("# Test:: testPerformInserts2"); |
|
488 |
System.out.println("# SQL:: " + builder.toString()); |
|
489 |
System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder))); |
|
490 |
System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder))); |
|
491 |
|
|
492 |
//# Test:: testPerformInserts2 |
|
493 |
//# SQL:: INSERT INTO [master].[dbo].[test1] ( [id], [name], [geom] ) VALUES ( ?, ?, geometry::STGeomFromWKB(?, ?) ) |
|
494 |
//# Variables:: [geom, id, name] |
|
495 |
//# Parametros:: ["id", "name", "geom", 4326] |
|
496 |
|
|
497 |
assertEquals( |
|
498 |
"INSERT INTO [master].[dbo].[test1] ( [id], [name], [geom] ) VALUES ( ?, ?, geometry::STGeomFromWKB(?, ?) )", |
|
499 |
builder.toString() |
|
500 |
); |
|
501 |
assertEquals( |
|
502 |
"[geom, id, name]", |
|
503 |
ArrayUtils.toString(getVariableNames(builder)) |
|
504 |
); |
|
505 |
assertEquals( |
|
506 |
"[\"id\", \"name\", \"geom\", 4326]", |
|
507 |
ArrayUtils.toString(getParameterNames(builder)) |
|
508 |
); |
|
509 |
} |
|
510 |
|
|
511 |
public void testPerformUpdates() throws Exception { |
|
512 |
IProjection proj = CRSFactory.getCRS("EPSG:4326"); |
|
513 |
|
|
514 |
SQLBuilder builder = createSQLBuilder(); |
|
515 |
|
|
516 |
builder.update().table().database("master").schema("dbo").name("test1"); |
|
517 |
builder.update().where().and( |
|
518 |
builder.eq( |
|
519 |
builder.column("id"), |
|
520 |
builder.parameter("id").as_variable() |
|
521 |
) |
|
522 |
); |
|
523 |
builder.update().column().name("name").with_value(builder.parameter("name")); |
|
524 |
builder.update().column().name("geom").with_value( |
|
525 |
builder.parameter("geom").as_geometry_variable().srs(builder.parameter().srs(proj)) |
|
526 |
); |
|
527 |
|
|
528 |
System.out.println("# Test:: testPerformUpdates"); |
|
529 |
System.out.println("# SQL:: " + builder.toString()); |
|
530 |
System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder))); |
|
531 |
System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder))); |
|
532 |
|
|
533 |
//# Test:: testPerformUpdates |
|
534 |
//# SQL:: UPDATE [master].[dbo].[test1] SET [name] = ?, [geom] = geometry::STGeomFromWKB(?, ?) WHERE ( ([id]) = (?) ) |
|
535 |
//# Variables:: [geom, id, name] |
|
536 |
//# Parametros:: ["name", "geom", 4326, "id"] |
|
537 |
|
|
538 |
assertEquals( |
|
539 |
"UPDATE [master].[dbo].[test1] SET [name] = ?, [geom] = geometry::STGeomFromWKB(?, ?) WHERE ( ([id]) = (?) )", |
|
540 |
builder.toString() |
|
541 |
); |
|
542 |
assertEquals( |
|
543 |
"[geom, id, name]", |
|
544 |
ArrayUtils.toString(getVariableNames(builder)) |
|
545 |
); |
|
546 |
assertEquals( |
|
547 |
"[\"name\", \"geom\", 4326, \"id\"]", |
|
548 |
ArrayUtils.toString(getParameterNames(builder)) |
|
549 |
); |
|
550 |
} |
|
551 |
|
|
552 |
} |
tags/org.gvsig.mysql-2.4.16/org.gvsig.mysql.provider/src/main/java/org/gvsig/mysql/dal/operations/MySQLOperationsFactory.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.mysql.dal.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.store.jdbc2.JDBCHelper; |
|
8 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CalculateEnvelopeOfColumnOperation; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureTypeOperation; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.OperationsFactoryBase; |
|
11 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
12 |
|
|
13 |
|
|
14 |
public class MySQLOperationsFactory extends OperationsFactoryBase { |
|
15 |
|
|
16 |
public MySQLOperationsFactory(JDBCHelper helper) { |
|
17 |
super(helper); |
|
18 |
} |
|
19 |
|
|
20 |
@Override |
|
21 |
public FetchFeatureTypeOperation createFetchFeatureType(EditableFeatureType type, String database, String schema, String table, List<String> primaryKeys, String defaultGeometryField, IProjection crs) { |
|
22 |
return new MySQLFetchFeatureTypeOperation(helper, type, database, schema, table, primaryKeys, defaultGeometryField, crs); |
|
23 |
} |
|
24 |
|
|
25 |
@Override |
|
26 |
public CalculateEnvelopeOfColumnOperation createCalculateEnvelopeOfColumn(String subquery, String database, String schema, String table, String columnName, String baseFilter, Envelope workingArea, IProjection crs) { |
|
27 |
return new MySQLCalculateEnvelopeOfColumnOperation(helper, subquery, table, schema, table, columnName, baseFilter, workingArea, crs); |
|
28 |
} |
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
} |
tags/org.gvsig.mysql-2.4.16/org.gvsig.mysql.provider/src/main/java/org/gvsig/mysql/dal/operations/MySQLCalculateEnvelopeOfColumnOperation.java | ||
---|---|---|
1 |
package org.gvsig.mysql.dal.operations; |
|
2 |
|
|
3 |
import java.sql.Connection; |
|
4 |
import java.sql.ResultSet; |
|
5 |
import java.sql.Statement; |
|
6 |
import org.apache.commons.lang3.StringUtils; |
|
7 |
import org.cresques.cts.IProjection; |
|
8 |
import org.gvsig.fmap.dal.exception.DataException; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
13 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CalculateEnvelopeOfColumnOperation; |
|
14 |
import org.gvsig.fmap.geom.Geometry; |
|
15 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
16 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
17 |
|
|
18 |
public class MySQLCalculateEnvelopeOfColumnOperation extends CalculateEnvelopeOfColumnOperation { |
|
19 |
|
|
20 |
public MySQLCalculateEnvelopeOfColumnOperation(JDBCHelper helper, String subquery, String dbName, String schemaName, String tableName, String columnName, String baseFilter, Envelope limit, IProjection crs) { |
|
21 |
super(helper, subquery, dbName, schemaName, tableName, columnName, baseFilter, limit, crs); |
|
22 |
} |
|
23 |
|
|
24 |
@Override |
|
25 |
public Envelope calculateEnvelopeOfColumn( |
|
26 |
Connection conn, |
|
27 |
String subquery, |
|
28 |
String dbName, |
|
29 |
String schemaName, |
|
30 |
String tableName, |
|
31 |
String columnName, |
|
32 |
String baseFilter, |
|
33 |
Envelope limit, |
|
34 |
IProjection crs |
|
35 |
) throws DataException { |
|
36 |
|
|
37 |
// |
|
38 |
// MySQL no soporta la funcion de agregado ST_Extent |
|
39 |
// |
|
40 |
JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder(); |
|
41 |
sqlbuilder.select().column().value( |
|
42 |
sqlbuilder.getAsGeometry( |
|
43 |
sqlbuilder.ST_Envelope( |
|
44 |
sqlbuilder.column(columnName) |
|
45 |
) |
|
46 |
) |
|
47 |
); |
|
48 |
|
|
49 |
if (StringUtils.isEmpty(subquery)) { |
|
50 |
sqlbuilder.select().from().table().database(dbName).schema(schemaName).name(tableName); |
|
51 |
} else { |
|
52 |
sqlbuilder.select().from().subquery(subquery); |
|
53 |
} |
|
54 |
|
|
55 |
if (StringUtils.isEmpty(baseFilter)) { |
|
56 |
if (limit != null) { |
|
57 |
sqlbuilder.select().where().set( |
|
58 |
sqlbuilder.ST_Intersects( |
|
59 |
sqlbuilder.ST_Envelope( |
|
60 |
sqlbuilder.column(columnName) |
|
61 |
), |
|
62 |
sqlbuilder.ST_Envelope( |
|
63 |
sqlbuilder.geometry(limit.getGeometry(), crs) |
|
64 |
) |
|
65 |
) |
|
66 |
); |
|
67 |
} |
|
68 |
} else { |
|
69 |
sqlbuilder.select().where().set( sqlbuilder.custom(baseFilter) ); |
|
70 |
if (limit != null) { |
|
71 |
sqlbuilder.select().where().and( |
|
72 |
sqlbuilder.ST_Intersects( |
|
73 |
sqlbuilder.ST_Envelope( |
|
74 |
sqlbuilder.column(columnName) |
|
75 |
), |
|
76 |
sqlbuilder.ST_Envelope( |
|
77 |
sqlbuilder.geometry(limit.getGeometry(), crs) |
|
78 |
) |
|
79 |
) |
|
80 |
); |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
String sql = sqlbuilder.select().toString(); |
|
85 |
|
|
86 |
Statement st = null; |
|
87 |
ResultSet rs = null; |
|
88 |
try { |
|
89 |
st = conn.createStatement(); |
|
90 |
rs = JDBCUtils.executeQuery(st, sql); |
|
91 |
Envelope env = GeometryLocator.getGeometryManager().createEnvelope(Geometry.SUBTYPES.GEOM2D); |
|
92 |
while( rs.next() ) { |
|
93 |
Geometry geom = this.helper.getGeometryFromColumn(rs, 1); |
|
94 |
if (geom != null) { |
|
95 |
env.add(geom); |
|
96 |
} |
|
97 |
} |
|
98 |
return env; |
|
99 |
} catch (Exception ex) { |
|
100 |
throw new JDBCSQLException(ex); |
|
101 |
} finally { |
|
102 |
JDBCUtils.closeQuietly(st); |
|
103 |
JDBCUtils.closeQuietly(rs); |
|
104 |
} |
|
105 |
} |
|
106 |
|
|
107 |
} |
tags/org.gvsig.mysql-2.4.16/org.gvsig.mysql.provider/src/main/java/org/gvsig/mysql/dal/operations/MySQLFetchFeatureTypeOperation.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.mysql.dal.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.cresques.cts.IProjection; |
|
13 |
import org.gvsig.fmap.dal.DataTypes; |
|
14 |
import org.gvsig.fmap.dal.exception.DataException; |
|
15 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
16 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
17 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
18 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
|
19 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
20 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureTypeOperation; |
|
21 |
import org.gvsig.fmap.geom.Geometry; |
|
22 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
23 |
import org.gvsig.fmap.geom.GeometryManager; |
|
24 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
25 |
|
|
26 |
public class MySQLFetchFeatureTypeOperation extends FetchFeatureTypeOperation { |
|
27 |
|
|
28 |
private static Map<String,GeometryType>mySQLGeometryTypes = null; |
|
29 |
|
|
30 |
public MySQLFetchFeatureTypeOperation( |
|
31 |
JDBCHelper helper |
|
32 |
) { |
|
33 |
super(helper); |
|
34 |
} |
|
35 |
|
|
36 |
private GeometryType getGT( |
|
37 |
GeometryManager manager, |
|
38 |
int type, |
|
39 |
int subtype |
|
40 |
) { |
|
41 |
try { |
|
42 |
return manager.getGeometryType(type, subtype); |
|
43 |
} catch (Exception ex) { |
|
44 |
return null; |
|
45 |
} |
|
46 |
} |
|
47 |
|
|
48 |
public MySQLFetchFeatureTypeOperation( |
|
49 |
JDBCHelper helper, |
|
50 |
EditableFeatureType featureType, |
|
51 |
String dbname, |
|
52 |
String schema, |
|
53 |
String table, |
|
54 |
List<String> primaryKeys, |
|
55 |
String defaultGeometryColumn, |
|
56 |
IProjection crs |
|
57 |
) { |
|
58 |
super(helper, featureType, dbname, schema, table, primaryKeys, defaultGeometryColumn, crs); |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
public void fetch(EditableFeatureType featureType, Connection conn, String dbname, String schema, String table, List<String> pks, String defaultGeometryColumn, IProjection crs) throws DataException { |
|
63 |
super.fetch(featureType, conn, dbname, schema, table, pks, defaultGeometryColumn, crs); |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
protected int getDataTypeFromMetadata( |
|
68 |
ResultSetMetaData rsMetadata, |
|
69 |
int colIndex |
|
70 |
) throws SQLException { |
|
71 |
if( rsMetadata.getColumnType(colIndex) != java.sql.Types.BINARY ) { |
|
72 |
return super.getDataTypeFromMetadata(rsMetadata, colIndex); |
|
73 |
} |
|
74 |
String typeName = rsMetadata.getColumnTypeName(colIndex); |
|
75 |
GeometryType gt = getGeometryTypeFromMySQLTypeName(typeName); |
|
76 |
if( gt==null ) { |
|
77 |
return super.getDataTypeFromMetadata(rsMetadata, colIndex); |
|
78 |
} |
|
79 |
return DataTypes.GEOMETRY; |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
protected void fetchGeometryTypeAndSRS( |
|
84 |
EditableFeatureAttributeDescriptor attr, |
|
85 |
ResultSetMetaData rsMetadata, |
|
86 |
int colIndex |
|
87 |
) { |
|
88 |
if( attr.getType()!=DataTypes.GEOMETRY ) { |
|
89 |
return; |
|
90 |
} |
|
91 |
try { |
|
92 |
String typeName = rsMetadata.getColumnTypeName(colIndex); |
|
93 |
GeometryType gt = getGeometryTypeFromMySQLTypeName(typeName); |
|
94 |
if( gt != null ) { |
|
95 |
attr.setGeometryType(gt); |
|
96 |
|
|
97 |
JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder(); |
|
98 |
sqlbuilder.select().column().name("f_table_name"); |
|
99 |
sqlbuilder.select().column().name("f_geometry_column"); |
|
100 |
// sqlbuilder.select().column().name("geometry_type"); |
|
101 |
sqlbuilder.select().column().name("type"); |
|
102 |
sqlbuilder.select().column().name("coord_dimension"); |
|
103 |
sqlbuilder.select().column().name("srid"); |
|
104 |
// sqlbuilder.select().column().name("spatial_index_enabled"); |
|
105 |
sqlbuilder.select().where().set( |
|
106 |
sqlbuilder.eq( |
|
107 |
sqlbuilder.column("f_table_name"), |
|
108 |
sqlbuilder.constant(this.getTablename()) |
|
109 |
) |
|
110 |
); |
|
111 |
sqlbuilder.select().where().and( |
|
112 |
sqlbuilder.eq( |
|
113 |
sqlbuilder.column("f_geometry_column"), |
|
114 |
sqlbuilder.constant(attr.getName()) |
|
115 |
) |
|
116 |
); |
|
117 |
sqlbuilder.select().from().table().name("geometry_columns"); |
|
118 |
Statement st = null; |
|
119 |
ResultSet rs = null; |
|
120 |
int srsid = -1; |
|
121 |
try { |
|
122 |
st = this.getConnection().createStatement(); |
|
123 |
rs = JDBCUtils.executeQuery(st, sqlbuilder.toString()); |
|
124 |
if (rs.next()) { |
|
125 |
srsid = rs.getInt("srid"); |
|
126 |
} |
|
127 |
} catch(Exception ex) { |
|
128 |
logger.warn("Can't read SRS from DDBB.",ex); |
|
129 |
} finally { |
|
130 |
JDBCUtils.closeQuietly(rs); |
|
131 |
JDBCUtils.closeQuietly(st); |
|
132 |
} |
|
133 |
if( srsid > 0 ) { |
|
134 |
attr.setSRS(this.helper.getProjectionFromSRSId(srsid)); |
|
135 |
} |
|
136 |
} |
|
137 |
|
|
138 |
|
|
139 |
} catch (SQLException ex) { |
|
140 |
// Do nothing |
|
141 |
} |
|
142 |
} |
|
143 |
|
|
144 |
private GeometryType getGeometryTypeFromMySQLTypeName(String typeName) { |
|
145 |
if( mySQLGeometryTypes==null ) { |
|
146 |
GeometryManager manager = GeometryLocator.getGeometryManager(); |
|
147 |
mySQLGeometryTypes = new HashMap<>(); |
|
148 |
mySQLGeometryTypes.put("POINT", getGT(manager, Geometry.TYPES.POINT,Geometry.SUBTYPES.GEOM2D)); |
|
149 |
|
|
150 |
mySQLGeometryTypes.put("LINESTRING", getGT(manager, Geometry.TYPES.LINE,Geometry.SUBTYPES.GEOM2D)); |
|
151 |
|
|
152 |
mySQLGeometryTypes.put("POLYGON", getGT(manager, Geometry.TYPES.POLYGON,Geometry.SUBTYPES.GEOM2D)); |
|
153 |
|
|
154 |
mySQLGeometryTypes.put("MULTIPOINT", getGT(manager, Geometry.TYPES.MULTIPOINT,Geometry.SUBTYPES.GEOM2D)); |
|
155 |
|
|
156 |
mySQLGeometryTypes.put("MULTILINESTRING", getGT(manager, Geometry.TYPES.MULTILINE,Geometry.SUBTYPES.GEOM2D)); |
|
157 |
|
|
158 |
mySQLGeometryTypes.put("MULTIPOLYGON", getGT(manager, Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM2D)); |
|
159 |
|
|
160 |
mySQLGeometryTypes.put("GEOMETRY", getGT(manager, Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM2D)); |
|
161 |
} |
|
162 |
return mySQLGeometryTypes.get(typeName); |
|
163 |
} |
|
164 |
|
|
165 |
} |
tags/org.gvsig.mysql-2.4.16/org.gvsig.mysql.provider/src/main/java/org/gvsig/mysql/dal/MySQLHelper.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.mysql.dal; |
|
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.cresques.cts.IProjection; |
|
29 |
import org.gvsig.fmap.dal.SQLBuilder; |
|
30 |
import org.gvsig.fmap.dal.resource.exception.AccessResourceException; |
|
31 |
import org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters; |
|
32 |
import org.gvsig.fmap.dal.store.jdbc.JDBCNewStoreParameters; |
|
33 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
|
34 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
35 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCDriverClassNotFoundException; |
|
36 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
37 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCHelperBase; |
|
38 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
39 |
import org.gvsig.mysql.dal.operations.MySQLOperationsFactory; |
|
40 |
|
|
41 |
import org.slf4j.Logger; |
|
42 |
import org.slf4j.LoggerFactory; |
|
43 |
|
|
44 |
public class MySQLHelper extends JDBCHelperBase { |
|
45 |
|
|
46 |
static final Logger logger = LoggerFactory.getLogger(MySQLHelper.class); |
|
47 |
|
|
48 |
public static final String NAME = "MySQL"; |
|
49 |
public static final String MySQLJDBCDriver = "com.mysql.jdbc.Driver"; |
|
50 |
|
|
51 |
public static String getConnectionURL(MySQLConnectionParameters params) { |
|
52 |
String connectionURL = MessageFormat.format( |
|
53 |
"jdbc:mysql://{0}:{1,number,#}/{2}", |
|
54 |
params.getHost(), |
|
55 |
params.getPort(), |
|
56 |
params.getDBName() |
|
57 |
); |
|
58 |
logger.debug("connectionURL: {}", connectionURL); |
|
59 |
return connectionURL; |
|
60 |
} |
|
61 |
|
|
62 |
private static class ConnectionProvider { |
|
63 |
|
|
64 |
private static boolean needRegisterDriver = true; |
|
65 |
|
|
66 |
private BasicDataSource dataSource = null; |
|
67 |
|
|
68 |
private final MySQLConnectionParameters connectionParameters; |
|
69 |
|
|
70 |
public ConnectionProvider(MySQLConnectionParameters connectionParameters) { |
|
71 |
this.connectionParameters = connectionParameters; |
|
72 |
} |
|
73 |
|
|
74 |
public Connection getConnection() throws SQLException { |
|
75 |
if (this.dataSource == null) { |
|
76 |
this.dataSource = this.createDataSource(); |
|
77 |
} |
|
78 |
Connection conn = this.dataSource.getConnection(); |
|
79 |
return conn; |
|
80 |
} |
|
81 |
|
|
82 |
private BasicDataSource createDataSource() throws SQLException { |
|
83 |
if (!this.isRegistered()) { |
|
84 |
this.registerDriver(); |
|
85 |
} |
|
86 |
JDBCConnectionParameters params = connectionParameters; |
|
87 |
|
|
88 |
BasicDataSource dataSource = new BasicDataSource(); |
|
89 |
dataSource.setDriverClassName(params.getJDBCDriverClassName()); |
|
90 |
|
|
91 |
dataSource.setUsername(params.getUser()); |
|
92 |
dataSource.setPassword(params.getPassword()); |
|
93 |
dataSource.setUrl(params.getUrl()); |
|
94 |
|
|
95 |
dataSource.setMaxWait(60L * 1000); |
|
96 |
return dataSource; |
|
97 |
} |
|
98 |
|
|
99 |
private boolean isRegistered() { |
|
100 |
return needRegisterDriver; |
|
101 |
} |
|
102 |
|
|
103 |
public void registerDriver() throws SQLException { |
|
104 |
String className = this.connectionParameters.getJDBCDriverClassName(); |
|
105 |
if (className == null) { |
|
106 |
return; |
|
107 |
} |
|
108 |
try { |
|
109 |
Class theClass = Class.forName(className); |
|
110 |
if (theClass == null) { |
|
111 |
throw new JDBCDriverClassNotFoundException(MySQLLibrary.NAME, className); |
|
112 |
} |
|
113 |
} catch (Exception e) { |
|
114 |
throw new SQLException("Can't register JDBC driver '" + className + "'.", e); |
|
115 |
} |
|
116 |
needRegisterDriver = false; |
|
117 |
} |
|
118 |
|
|
119 |
} |
|
120 |
|
|
121 |
private ConnectionProvider connectionProvider = null; |
|
122 |
|
|
123 |
public MySQLHelper(JDBCConnectionParameters connectionParameters) { |
|
124 |
super(connectionParameters); |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public Connection getConnection() throws AccessResourceException { |
|
129 |
try { |
|
130 |
if (this.connectionProvider == null) { |
|
131 |
this.connectionProvider = new ConnectionProvider(this.getConnectionParameters()); |
|
132 |
} |
|
133 |
return this.connectionProvider.getConnection(); |
|
134 |
} catch (SQLException ex) { |
|
135 |
throw new AccessResourceException(MySQLLibrary.NAME, ex); |
|
136 |
} |
|
137 |
} |
|
138 |
|
|
139 |
@Override |
|
140 |
public MySQLConnectionParameters getConnectionParameters() { |
|
141 |
return (MySQLConnectionParameters) super.getConnectionParameters(); |
|
142 |
} |
|
143 |
|
|
144 |
@Override |
|
145 |
public String getConnectionURL() { |
|
146 |
return getConnectionURL(this.getConnectionParameters()); |
|
147 |
} |
|
148 |
|
|
149 |
@Override |
|
150 |
protected String getResourceType() { |
|
151 |
return MySQLLibrary.NAME; |
|
152 |
} |
|
153 |
|
|
154 |
@Override |
|
155 |
public String getProviderName() { |
|
156 |
return MySQLLibrary.NAME; |
|
157 |
} |
|
158 |
|
|
159 |
@Override |
|
160 |
public JDBCSQLBuilderBase createSQLBuilder() { |
|
161 |
return new MySQLSQLBuilder(this); |
|
162 |
} |
|
163 |
|
|
164 |
@Override |
|
165 |
public OperationsFactory getOperations() { |
|
166 |
if (this.operationsFactory == null) { |
|
167 |
this.operationsFactory = new MySQLOperationsFactory(this); |
|
168 |
} |
|
169 |
return operationsFactory; |
|
170 |
} |
|
171 |
|
|
172 |
@Override |
|
173 |
public SQLBuilder.GeometrySupportType getGeometrySupportType() { |
|
174 |
return SQLBuilder.GeometrySupportType.WKB; |
|
175 |
} |
|
176 |
|
|
177 |
@Override |
|
178 |
public boolean hasSpatialFunctions() { |
|
179 |
return true; |
|
180 |
} |
|
181 |
|
|
182 |
@Override |
|
183 |
public boolean canWriteGeometry(int geometryType, int geometrySubtype) { |
|
184 |
return true; |
|
185 |
} |
|
186 |
|
|
187 |
@Override |
|
188 |
public String getQuoteForIdentifiers() { |
|
189 |
return "\""; |
|
190 |
} |
|
191 |
|
|
192 |
@Override |
|
193 |
public boolean allowAutomaticValues() { |
|
194 |
return true; |
|
195 |
} |
|
196 |
|
|
197 |
@Override |
|
198 |
public boolean supportOffsetInSelect() { |
|
199 |
return true; |
|
200 |
} |
|
201 |
|
|
202 |
@Override |
|
203 |
public String getQuoteForStrings() { |
|
204 |
return "'"; |
|
205 |
} |
|
206 |
|
|
207 |
@Override |
|
208 |
public int getSRSCode(IProjection crs) { |
|
209 |
// TODO: ir a buscarlo a la BBDD a ver donde puede estar |
|
210 |
return super.getSRSCode(crs); |
|
211 |
} |
|
212 |
|
|
213 |
@Override |
|
214 |
public IProjection getProjectionFromSRSId(int srsid) { |
|
215 |
// TODO: ir a buscarlo a la BBDD a ver donde puede estar |
|
216 |
return super.getProjectionFromSRSId(srsid); |
|
217 |
} |
|
218 |
|
|
219 |
@Override |
|
220 |
public String getSourceId(JDBCStoreParameters parameters) { |
|
221 |
return parameters.getDBName() + "." + |
|
222 |
parameters.getSchema()+ "." + |
|
223 |
parameters.getTable(); |
|
224 |
} |
|
225 |
|
|
226 |
@Override |
|
227 |
public JDBCNewStoreParameters createNewStoreParameters() { |
|
228 |
return new MySQLNewStoreParameters(); |
|
229 |
} |
|
230 |
|
|
231 |
@Override |
|
232 |
public JDBCStoreParameters createOpenStoreParameters() { |
|
233 |
return new MySQLStoreParameters(); |
|
234 |
} |
|
235 |
|
|
236 |
@Override |
|
237 |
public JDBCServerExplorerParameters createServerExplorerParameters() { |
|
238 |
return new MySQLExplorerParameters(); |
|
239 |
} |
|
240 |
|
|
241 |
} |
tags/org.gvsig.mysql-2.4.16/org.gvsig.mysql.provider/src/main/java/org/gvsig/mysql/dal/MySQLStoreProviderFactory.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.mysql.dal; |
|
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 MySQLStoreProviderFactory extends JDBCStoreProviderFactory { |
|
15 |
|
|
16 |
private static final String NAME = MySQLLibrary.NAME; |
|
17 |
|
|
18 |
public MySQLStoreProviderFactory() { |
|
19 |
super( |
|
20 |
NAME, |
|
21 |
"MySQL store" |
|
22 |
); |
|
23 |
} |
|
24 |
|
|
25 |
@Override |
|
26 |
public JDBCStoreProvider createProvider( |
|
27 |
DataParameters parameters, |
|
28 |
DataStoreProviderServices providerServices |
|
29 |
) throws InitializeException { |
|
30 |
JDBCHelper helper = new MySQLHelper((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 MySQLStoreParameters(); |
|
41 |
return params; |
|
42 |
} |
|
43 |
|
|
44 |
} |
tags/org.gvsig.mysql-2.4.16/org.gvsig.mysql.provider/src/main/java/org/gvsig/mysql/dal/MySQLStoreParameters.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.mysql.dal; |
|
23 |
|
|
24 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
25 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
26 |
|
|
27 |
public class MySQLStoreParameters extends JDBCStoreParameters implements MySQLConnectionParameters { |
|
28 |
|
|
29 |
private final MySQLConnectionParametersHelper helper; |
|
30 |
|
|
31 |
public MySQLStoreParameters() { |
|
32 |
super( |
|
33 |
MySQLLibrary.NAME + "StoreParameters", |
|
34 |
MySQLLibrary.NAME |
|
35 |
); |
|
36 |
this.helper = new MySQLConnectionParametersHelper(this); |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
public String getUrl() { |
|
41 |
return this.helper.getUrl(); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public void validate() throws ValidateDataParametersException { |
|
46 |
this.helper.validate(); |
|
47 |
super.validate(); |
|
48 |
} |
|
49 |
|
|
50 |
} |
tags/org.gvsig.mysql-2.4.16/org.gvsig.mysql.provider/src/main/java/org/gvsig/mysql/dal/MySQLConnectionParameters.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.mysql.dal; |
|
3 |
|
|
4 |
import org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters; |
|
5 |
|
|
6 |
public interface MySQLConnectionParameters extends JDBCConnectionParameters { |
|
7 |
|
|
8 |
} |
tags/org.gvsig.mysql-2.4.16/org.gvsig.mysql.provider/src/main/java/org/gvsig/mysql/dal/MySQLConnectionParametersHelper.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.mysql.dal; |
|
3 |
|
|
4 |
import org.apache.commons.lang3.StringUtils; |
|
5 |
import org.gvsig.fmap.dal.DataParameters; |
|
6 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
7 |
import org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters; |
|
8 |
|
|
9 |
|
|
10 |
public class MySQLConnectionParametersHelper { |
|
11 |
|
|
12 |
private final JDBCConnectionParameters parameters; |
|
13 |
|
|
14 |
|
|
15 |
public MySQLConnectionParametersHelper(JDBCConnectionParameters parameters) { |
|
16 |
this.parameters = parameters; |
|
17 |
} |
|
18 |
|
|
19 |
public String getUrl() { |
|
20 |
String url = (String) this.getDynValue(JDBCConnectionParameters.URL_PARAMTER_NAME); |
|
21 |
if( StringUtils.isEmpty(url) ) { |
|
22 |
url = MySQLHelper.getConnectionURL((MySQLConnectionParameters) this.parameters); |
|
23 |
this.setDynValue(JDBCConnectionParameters.URL_PARAMTER_NAME,url); |
|
24 |
} |
|
25 |
return url; |
|
26 |
} |
|
27 |
|
|
28 |
public void validate() throws ValidateDataParametersException { |
|
29 |
// Do nothing |
|
30 |
} |
|
31 |
|
|
32 |
private Object getDynValue(String name) { |
|
33 |
return ((DataParameters)this.parameters).getDynValue(name); |
|
34 |
} |
|
35 |
|
|
36 |
private void setDynValue(String name, Object value) { |
|
37 |
((DataParameters)this.parameters).setDynValue(name,value); |
|
38 |
} |
|
39 |
|
|
40 |
} |
tags/org.gvsig.mysql-2.4.16/org.gvsig.mysql.provider/src/main/java/org/gvsig/mysql/dal/MySQLExplorerParameters.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.mysql.dal; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
28 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
|
29 |
|
|
30 |
public class MySQLExplorerParameters extends |
|
31 |
JDBCServerExplorerParameters |
|
32 |
implements |
|
33 |
MySQLConnectionParameters |
|
34 |
{ |
|
35 |
|
|
36 |
private final MySQLConnectionParametersHelper helper; |
|
37 |
|
|
38 |
public MySQLExplorerParameters() { |
|
39 |
super( |
|
40 |
MySQLLibrary.NAME + "ServerExplorerParameters", |
|
41 |
MySQLLibrary.NAME |
|
42 |
); |
|
43 |
this.helper = new MySQLConnectionParametersHelper(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 |
super.validate(); |
|
55 |
} |
|
56 |
|
|
57 |
} |
tags/org.gvsig.mysql-2.4.16/org.gvsig.mysql.provider/src/main/java/org/gvsig/mysql/dal/MySQLLibrary.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.mysql.dal; |
|
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 MySQLLibrary extends AbstractLibrary { |
|
35 |
|
|
36 |
public static final String NAME = "MySQL"; |
|
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(MySQLHelper.MySQLJDBCDriver); |
|
57 |
} catch(Throwable th) { |
|
58 |
MySQLHelper.logger.warn("Can't load MySQL JDBC Driver.",th); |
|
59 |
} |
|
60 |
|
Also available in: Unified diff