Revision 38035 trunk/extensions/extJDBC/src/com/iver/cit/gvsig/fmap/drivers/jdbc/postgis/PostGisDriver.java
PostGisDriver.java | ||
---|---|---|
61 | 61 |
import java.util.HashMap; |
62 | 62 |
import java.util.Hashtable; |
63 | 63 |
import java.util.Map; |
64 |
import java.util.Random; |
|
64 | 65 |
|
65 | 66 |
import org.apache.log4j.Logger; |
66 | 67 |
import org.joda.time.DateTime; |
... | ... | |
140 | 141 |
|
141 | 142 |
private String completeWhere; |
142 | 143 |
|
143 |
private String provCursorName = null; |
|
144 |
|
|
145 |
int numProvCursors = 0; |
|
146 |
|
|
147 | 144 |
boolean bShapeTypeRevised = false; |
148 | 145 |
|
149 | 146 |
private int actual_position; |
... | ... | |
394 | 391 |
return geomIterator; |
395 | 392 |
} |
396 | 393 |
|
397 |
private PostGisFeatureIterator myGetFeatureIterator(String sql) |
|
398 |
throws ReadDriverException { |
|
399 |
PostGisFeatureIterator geomIterator = null; |
|
400 |
try { |
|
401 |
// st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, |
|
402 |
// ResultSet.CONCUR_READ_ONLY); |
|
403 |
|
|
404 |
// st = conn.createStatement |
|
405 |
if (provCursorName != null) { |
|
406 |
/* |
|
407 |
* st.execute("BEGIN"); st.execute("CLOSE " + provCursorName); |
|
408 |
* bCursorActivo = false; st.execute("COMMIT"); |
|
409 |
*/ |
|
410 |
numProvCursors++; |
|
411 |
} |
|
412 |
// st.execute("BEGIN"); |
|
413 |
provCursorName = getTableName() + myCursorId + "wkb_cursor_prov_" |
|
414 |
+ System.currentTimeMillis() + "" + numProvCursors; |
|
415 |
|
|
416 |
// st.execute("BEGIN"); |
|
417 |
bCursorActivo = true; |
|
418 |
// ResultSet rs = st.executeQuery(sql); |
|
419 |
geomIterator = new PostGisFeatureIterator( |
|
420 |
((ConnectionJDBC) conn).getConnection(), provCursorName, |
|
421 |
sql); |
|
422 |
} catch (SQLException e) { |
|
423 |
// e.printStackTrace(); |
|
424 |
// e.printStackTrace(); |
|
425 |
// SqlDriveExceptionType type = new SqlDriveExceptionType(); |
|
426 |
// type.setDriverName("PostGIS Driver"); |
|
427 |
// type.setSql(sql); |
|
428 |
// type.setLayerName(getTableName()); |
|
429 |
// type.setSchema(null); |
|
430 |
throw new ReadDriverException("PostGIS Driver", e); |
|
431 |
// throw new DriverException(e); |
|
432 |
// return null; |
|
394 |
private PostGisFeatureIterator myGetFeatureIterator(String sql) |
|
395 |
throws ReadDriverException { |
|
396 |
PostGisFeatureIterator geomIterator = null; |
|
397 |
try { |
|
398 |
String provCursorName = "wkb_cursor_prov_" |
|
399 |
+ Long.toString(Math.abs(new Random().nextLong())) |
|
400 |
+ getTableName(); |
|
401 |
bCursorActivo = true; |
|
402 |
geomIterator = new PostGisFeatureIterator( |
|
403 |
((ConnectionJDBC) conn).getConnection(), provCursorName, |
|
404 |
sql); |
|
405 |
} catch (SQLException e) { |
|
406 |
throw new ReadDriverException("PostGIS Driver", e); |
|
433 | 407 |
} |
408 |
return geomIterator; |
|
409 |
} |
|
434 | 410 |
|
435 |
return geomIterator; |
|
436 |
} |
|
437 |
|
|
438 | 411 |
public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG) |
439 | 412 |
throws ReadDriverException { |
440 |
if (workingArea != null) |
|
441 |
r = r.createIntersection(workingArea); |
|
413 |
if (workingArea != null) { |
|
414 |
r = r.createIntersection(workingArea); |
|
415 |
} |
|
442 | 416 |
|
443 | 417 |
String sqlAux; |
444 | 418 |
if (canReproject(strEPSG)) { |
Also available in: Unified diff