Revision 38044
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/writers/JdbcWriter.java | ||
---|---|---|
4 | 4 |
import java.sql.ResultSet; |
5 | 5 |
import java.sql.ResultSetMetaData; |
6 | 6 |
import java.sql.SQLException; |
7 |
import java.util.ArrayList; |
|
7 | 8 |
|
8 | 9 |
import org.apache.log4j.Logger; |
9 | 10 |
|
... | ... | |
30 | 31 |
private boolean bCreateTable; |
31 | 32 |
|
32 | 33 |
private ResultSetMetaData metaData = null; |
34 |
|
|
35 |
protected ArrayList<Integer> rowsToDelete = null; |
|
33 | 36 |
|
34 | 37 |
public JdbcWriter(){ |
35 | 38 |
} |
... | ... | |
40 | 43 |
System.out.println("INICIO CONEXI?N DE ESCRITURA"); |
41 | 44 |
} |
42 | 45 |
public void preProcess() throws StartWriterVisitorException { |
43 |
numRecord = 0; |
|
44 | 46 |
try { |
47 |
numRecord = 0; |
|
45 | 48 |
conn.setAutoCommit(false); |
49 |
rowsToDelete = new ArrayList<Integer>(); |
|
46 | 50 |
} catch (SQLException e) { |
47 | 51 |
if (conn instanceof JdbcOdbcConnection) { |
48 | 52 |
logger.warn("Driver does not allow autocommit method: " + conn.getClass().getName()); |
... | ... | |
100 | 104 |
} |
101 | 105 |
break; |
102 | 106 |
case IRowEdited.STATUS_DELETED: |
103 |
rs.absolute(editedRow.getIndex()+1); |
|
104 |
rs.deleteRow(); |
|
107 |
rowsToDelete.add(editedRow.getIndex()+1); |
|
105 | 108 |
break; |
106 | 109 |
} |
107 | 110 |
numRecord++; |
... | ... | |
122 | 125 |
|
123 | 126 |
public void postProcess() throws StopWriterVisitorException { |
124 | 127 |
try { |
128 |
for (int i=rowsToDelete.size()-1; i>=0; i--) { |
|
129 |
rs.absolute(rowsToDelete.get(i)); |
|
130 |
rs.deleteRow(); |
|
131 |
} |
|
132 |
|
|
125 | 133 |
conn.commit(); |
126 | 134 |
} catch (SQLException e) { |
127 | 135 |
try { |
trunk/libraries/libGDBMS/src/main/java/com/hardcode/gdbms/engine/data/db/DBDataSourceAdapter.java | ||
---|---|---|
258 | 258 |
sem = 0; |
259 | 259 |
|
260 | 260 |
driver.close(); |
261 |
if (this.con == null) {
|
|
261 |
if (this.con != null) {
|
|
262 | 262 |
con.close(); |
263 | 263 |
con = null; |
264 | 264 |
} |
Also available in: Unified diff