Revision 20376 trunk/libraries/libDataSourceDBBaseDrivers/src/org/gvsig/data/datastores/vectorial/db/jdbc/JDBCFeaturesWriter.java
JDBCFeaturesWriter.java | ||
---|---|---|
4 | 4 |
import java.sql.SQLException; |
5 | 5 |
import java.sql.Statement; |
6 | 6 |
|
7 |
import org.gvsig.data.datastores.vectorial.ISelectiveWriter; |
|
7 | 8 |
import org.gvsig.data.datastores.vectorial.db.DBFeatureType; |
8 | 9 |
import org.gvsig.data.datastores.vectorial.db.jdbc.h2.H2StoreParameters; |
10 |
import org.gvsig.data.datastores.vectorial.db.jdbc.postgresql.PostgresqlStore; |
|
11 |
import org.gvsig.data.exception.OpenException; |
|
12 |
import org.gvsig.data.exception.ReadException; |
|
13 |
import org.gvsig.data.exception.WriteException; |
|
9 | 14 |
import org.gvsig.data.vectorial.IFeatureStore; |
10 | 15 |
|
11 |
public abstract class JDBCFeaturesWriter { |
|
16 |
public abstract class JDBCFeaturesWriter implements ISelectiveWriter{
|
|
12 | 17 |
|
13 | 18 |
protected Connection conex; |
19 |
protected JDBCStore store; |
|
20 |
protected boolean previousAutocommit; |
|
14 | 21 |
|
22 |
|
|
23 |
public void init(IFeatureStore store) { |
|
24 |
this.store = (JDBCStore)store; |
|
25 |
this.conex = this.store.getConnection(); |
|
26 |
} |
|
27 |
|
|
28 |
|
|
29 |
public void preProcess() throws WriteException, ReadException { |
|
30 |
try { |
|
31 |
previousAutocommit = conex.getAutoCommit(); |
|
32 |
conex.setAutoCommit(false); |
|
33 |
} catch (SQLException e) { |
|
34 |
throw new WriteException(this.store.getName(),e); |
|
35 |
} |
|
36 |
|
|
37 |
} |
|
38 |
|
|
39 |
public void postProcess() throws OpenException, WriteException { |
|
40 |
try { |
|
41 |
conex.commit(); |
|
42 |
if (previousAutocommit){ |
|
43 |
conex.setAutoCommit(true); |
|
44 |
} |
|
45 |
} catch (SQLException e) { |
|
46 |
throw new WriteException(this.store.getName(),e); |
|
47 |
} |
|
48 |
} |
|
49 |
|
|
50 |
public void cancelProcess() throws WriteException { |
|
51 |
try { |
|
52 |
conex.rollback(); |
|
53 |
if (previousAutocommit){ |
|
54 |
conex.setAutoCommit(true); |
|
55 |
} |
|
56 |
} catch (SQLException e) { |
|
57 |
throw new WriteException(this.store.getName(),e); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
15 | 61 |
} |
Also available in: Unified diff