Revision 38035
trunk/extensions/extJDBC/src/com/iver/cit/gvsig/fmap/drivers/jdbc/postgis/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)) { |
trunk/extensions/extJDBC/src/com/iver/cit/gvsig/fmap/drivers/jdbc/postgis/PostGisFeatureIterator.java | ||
---|---|---|
56 | 56 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
57 | 57 |
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition; |
58 | 58 |
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator; |
59 |
import com.iver.cit.gvsig.fmap.drivers.WKBParser2; |
|
60 | 59 |
import com.iver.cit.gvsig.fmap.drivers.WKBParser3; |
61 |
import com.iver.cit.gvsig.fmap.drivers.XTypes; |
|
62 | 60 |
|
63 | 61 |
/** |
64 | 62 |
* @author FJP |
... | ... | |
217 | 215 |
* |
218 | 216 |
* @see com.iver.cit.gvsig.fmap.drivers.IFeatureIterator#closeIterator() |
219 | 217 |
*/ |
220 |
public void closeIterator() throws ReadDriverException { |
|
221 |
try { |
|
222 |
numReg = 0; |
|
223 |
|
|
224 |
// st.execute("CLOSE " + cursorName); |
|
225 |
// st.execute("COMMIT"); |
|
226 |
rs.close(); |
|
227 |
} catch (SQLException e) { |
|
228 |
// SqlDriveExceptionType type = new SqlDriveExceptionType(); |
|
229 |
// type.setDriverName("PostGIS Driver"); |
|
230 |
// try { |
|
231 |
// type.setSql(rs.getStatement().toString()); |
|
232 |
// } catch (SQLException e1) { |
|
233 |
// e1.printStackTrace(); |
|
234 |
// } |
|
235 |
throw new ReadDriverException("PostGIS Driver",e); |
|
236 |
// throw new DriverException(e); |
|
237 |
} |
|
238 |
// st.execute("COMMIT"); |
|
239 |
// st.close(); |
|
240 |
|
|
218 |
public void closeIterator() throws ReadDriverException { |
|
219 |
try { |
|
220 |
numReg = 0; |
|
221 |
// st.execute("CLOSE " + cursorName); fpuga: Not need as we are |
|
222 |
// using non-holdable cursor |
|
223 |
st.execute("COMMIT"); |
|
224 |
rs.close(); |
|
225 |
st.close(); |
|
226 |
} catch (SQLException e) { |
|
227 |
throw new ReadDriverException("PostGIS Driver", e); |
|
241 | 228 |
} |
229 |
} |
|
242 | 230 |
|
243 | 231 |
public void setLyrDef(DBLayerDefinition lyrDef) { |
244 | 232 |
this.lyrDef = lyrDef; |
Also available in: Unified diff