Revision 11971 trunk/extensions/extJDBC/src/com/iver/cit/gvsig/fmap/drivers/jdbc/postgis/PostGISWriter.java

View differences:

PostGISWriter.java
15 15
import com.iver.cit.gvsig.exceptions.visitors.StopWriterVisitorException;
16 16
import com.iver.cit.gvsig.fmap.core.FShape;
17 17
import com.iver.cit.gvsig.fmap.core.IFeature;
18
import com.iver.cit.gvsig.fmap.drivers.ConnectionJDBC;
18 19
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition;
19 20
import com.iver.cit.gvsig.fmap.drivers.FieldDescription;
21
import com.iver.cit.gvsig.fmap.drivers.IConnection;
20 22
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition;
21 23
import com.iver.cit.gvsig.fmap.edition.IFieldManager;
22 24
import com.iver.cit.gvsig.fmap.edition.IRowEdited;
......
30 32

  
31 33
	private DBLayerDefinition lyrDef;
32 34

  
33
	private Connection conex;
35
	private IConnection conex;
34 36

  
35 37
	private Statement st;
36 38

  
......
58 60
		conex = lyrDef.getConnection();
59 61

  
60 62
		try {
61
			st = conex.createStatement();
63
			st = ((ConnectionJDBC)conex).getConnection().createStatement();
62 64

  
63 65
			if (bCreateTable) {
64 66
				try {
65
					st.execute("DROP TABLE " + lyrDef.getTableName() + ";");
67
					st.execute("DROP TABLE " + lyrDef.getComposedTableName() + ";");
66 68
				} catch (SQLException e1) {
67 69
					// Si no existe la tabla, no hay que borrarla.
68 70
				}
......
88 90
				 * VALUES (2,GeometryFromText('LINESTRING(189141 244158,189265
89 91
				 * 244817)',-1),'Geordie Rd'); COMMIT;
90 92
				 */
91
				conex.commit();
93
				((ConnectionJDBC)conex).getConnection().commit();
92 94
			}
93
			conex.setAutoCommit(false);
94
			fieldManager = new JdbcFieldManager(conex, lyrDef.getTableName());
95
			((ConnectionJDBC)conex).getConnection().setAutoCommit(false);
96
			fieldManager = new JdbcFieldManager(((ConnectionJDBC)conex).getConnection(), lyrDef.getTableName());
95 97

  
96 98
		} catch (SQLException e) {
97 99
			throw new InitializeWriterException(getName(),e);
......
110 112

  
111 113
        ResultSet rsAux;
112 114
		try {
113
			conex.rollback();
115
				((ConnectionJDBC)conex).getConnection().rollback();
114 116
			alterTable();
115 117

  
116 118
			rsAux = st.executeQuery("SHOW server_encoding;");
......
178 180

  
179 181
	public void postProcess() throws StopWriterVisitorException {
180 182
		try {
181
			conex.setAutoCommit(true);
183
			((ConnectionJDBC)conex).getConnection().setAutoCommit(true);
182 184
		} catch (SQLException e) {
183 185
			throw new StopWriterVisitorException(getName(),e);
184 186
		}
......
245 247
		bCreateTable = createTable;
246 248
	}
247 249

  
248
	/**
249
	 * @return Returns the bWriteAll.
250
	 */
251
	public boolean isWriteAll() {
252
		return bWriteAll;
253
	}
254

  
255
	/**
256
	 * @param writeAll
257
	 *            The bWriteAll to set.
258
	 */
259
	public void setWriteAll(boolean writeAll) {
260
		bWriteAll = writeAll;
261
	}
262

  
263

  
264
//	public void setFlatness(double flatness) {
265
//		this.flatness = flatness;
266
//	}
267

  
268 250
	public FieldDescription[] getOriginalFields() {
269 251
		return lyrDef.getFieldsDesc();
270 252
	}
......
299 281
	public boolean canSaveEdits() {
300 282
		// TODO: Revisar los permisos de la tabla en cuesti?n.
301 283
		try {
302
			return !conex.isReadOnly();
284
			return !((ConnectionJDBC)conex).getConnection().isReadOnly();
303 285
		} catch (SQLException e) {
304 286
			// TODO Auto-generated catch block
305 287
			e.printStackTrace();

Also available in: Unified diff