Revision 364

View differences:

trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLExplorerFactory.java
13 13

  
14 14
public class PostgreSQLExplorerFactory extends JDBCServerExplorerFactory {
15 15

  
16
    private static final String NAME = PostgreSQLHelper.NAME;
16
    private static final String NAME = PostgreSQLLibrary.NAME;
17 17
    
18 18
    public PostgreSQLExplorerFactory() {
19 19
        super(
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLNewStoreParameters.java
35 35
    
36 36
    public PostgreSQLNewStoreParameters() {
37 37
        super(
38
            PostgreSQLHelper.NAME + "NewStoreParameters", 
39
            PostgreSQLHelper.NAME
38
            PostgreSQLLibrary.NAME + "NewStoreParameters", 
39
            PostgreSQLLibrary.NAME
40 40
        );
41 41
        this.helper = new PostgreSQLConnectionParametersHelper(this);
42 42
    }
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLHelper.java
9 9
import org.apache.commons.dbcp.BasicDataSource;
10 10
import org.apache.commons.lang3.BooleanUtils;
11 11
import org.apache.commons.lang3.StringUtils;
12
import org.cresques.cts.IProjection;
13 12
import org.gvsig.fmap.dal.DataTypes;
14 13
import org.gvsig.fmap.dal.ExpressionBuilder;
15 14
import org.gvsig.fmap.dal.SQLBuilder;
......
42 41

  
43 42
    static final Logger logger = LoggerFactory.getLogger(PostgreSQLHelper.class);
44 43

  
45
    public static final String NAME = "PostgreSQL";
46 44
    public static final String POSTGRESQL_JDBC_DRIVER = "org.postgresql.Driver";
47 45
    
48 46
    public static String getConnectionURL(PostgreSQLConnectionParameters params) {
......
122 120
            try {
123 121
                Class theClass = Class.forName(className);
124 122
                if (theClass == null) {
125
                    throw new JDBCDriverClassNotFoundException(NAME, className);
123
                    throw new JDBCDriverClassNotFoundException(PostgreSQLLibrary.NAME, className);
126 124
                }
127 125
            } catch (Exception e) {
128 126
                throw new SQLException("Can't register JDBC driver '" + className + "'.", e);
......
147 145
            }
148 146
            return this.connectionProvider.getConnection();
149 147
        } catch (SQLException ex) {
150
            throw new AccessResourceException(NAME, ex);
148
            throw new AccessResourceException(PostgreSQLLibrary.NAME, ex);
151 149
        }
152 150
    }
153 151
    
......
163 161

  
164 162
    @Override
165 163
    protected String getResourceType() {
166
        return NAME;
164
        return PostgreSQLLibrary.NAME;
167 165
    }
168 166

  
169 167
    @Override
170 168
    public String getProviderName() {
171
        return NAME;
169
        return PostgreSQLLibrary.NAME;
172 170
    }
173 171

  
174 172
    @Override
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLStoreProviderFactory.java
12 12

  
13 13

  
14 14
public class PostgreSQLStoreProviderFactory extends JDBCStoreProviderFactory {
15

  
16
    private static final String NAME = PostgreSQLHelper.NAME;
17 15
    
18 16
    public PostgreSQLStoreProviderFactory() {
19 17
        super(
20
                NAME, 
18
                PostgreSQLLibrary.NAME, 
21 19
                "PostgreSQL store"
22 20
        );
23 21
    }
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/operations/PostgreSQLAppendOperation.java
4 4
import org.gvsig.fmap.dal.exception.DataException;
5 5
import org.gvsig.fmap.dal.feature.FeatureType;
6 6
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
7
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCExecuteSQLException;
8
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCTransactionRollbackException;
9 7
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
10 8
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
11 9
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.AppendOperation;
......
31 29

  
32 30
    @Override
33 31
    public void append(FeatureProvider feature) throws DataException {
32
        int n;
34 33
        try {
35
            this.connection.setAutoCommit(false);
36
            try {
37
                getHelper().setPreparedStatementParameters(preparedStatement, sqlbuilder, type, feature);
38
                int n = JDBCUtils.executeUpdate(this.preparedStatement,this.sql);
39
                if ( n > 0) {
40
                    this.connection.commit();
41
                    return;
42
                }              
43
                this.connection.rollback();
44
            } catch(Exception ex) {
45
                try {
46
                    this.connection.rollback();
47
                } catch (Exception e1) {
48
                    throw new JDBCTransactionRollbackException(e1, ex);
49
                }                
50
                throw new JDBCExecuteSQLException(this.sql,ex);
51
            } 
52
            throw new JDBCExecuteSQLException(this.sql,null);
53

  
54
        } catch (JDBCExecuteSQLException ex) {
55
            throw ex;
56
        } catch (Exception ex) {
57
            throw new JDBCExecuteSQLException(this.sql,ex);
34
            getHelper().setPreparedStatementParameters(preparedStatement, sqlbuilder, type, feature);
35
            n = JDBCUtils.executeUpdate(this.preparedStatement,this.sql);
36
        } catch(Exception ex) {
37
            throw new RuntimeException("Can't insert feature.", ex);
58 38
        }
39
        if( n<1 ) {
40
            throw new RuntimeException("Can't insert feature (n="+n+").");
41
        }
59 42
    }
43
    
60 44
}
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/operations/PostgreSQLFetchFeatureTypeOperation.java
127 127
            if( !StringUtils.isEmpty(srsid) ) {
128 128
                attr.setSRS(this.helper.getProjectionFromDatabaseCode(srsid));
129 129
            }
130
        } catch (SQLException ex) {
130
        } catch (Exception ex) {
131 131
            logger.debug("Can't get geometry type and srs from column '"+attr.getName()+"'.",ex);
132 132
        }
133 133
    }
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLStoreParameters.java
30 30
    
31 31
    public PostgreSQLStoreParameters() {
32 32
        super(
33
                PostgreSQLHelper.NAME + "StoreParameters",
34
                PostgreSQLHelper.NAME
33
                PostgreSQLLibrary.NAME + "StoreParameters",
34
                PostgreSQLLibrary.NAME
35 35
        );
36 36
        this.helper = new PostgreSQLConnectionParametersHelper(this);
37 37
    }
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLExplorerParameters.java
37 37

  
38 38
    public PostgreSQLExplorerParameters() {
39 39
        super(
40
                PostgreSQLHelper.NAME + "ServerExplorerParameters",
41
                PostgreSQLHelper.NAME
40
                PostgreSQLLibrary.NAME + "ServerExplorerParameters",
41
                PostgreSQLLibrary.NAME
42 42
        );
43 43
        this.helper = new PostgreSQLConnectionParametersHelper(this);
44 44
    }
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLLibrary.java
14 14

  
15 15
public class PostgreSQLLibrary extends AbstractLibrary {
16 16

  
17
    public static final String NAME = PostgreSQLHelper.NAME;
17
    public static final String NAME = "PostgreSQL";
18 18

  
19 19
    @Override
20 20
    public void doRegistration() {
trunk/org.gvsig.postgresql/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
36 36
      <includes>
37 37
		<include>postgresql:postgresql</include>
38 38
		<include>commons-dbcp:commons-dbcp</include>
39
		<include>commons-collections:commons-collections</include>
40 39
		<include>commons-pool:commons-pool</include>
41 40
      </includes>
42 41
    </dependencySet>
trunk/org.gvsig.postgresql/org.gvsig.postgresql.app/org.gvsig.postgresql.app.mainplugin/pom.xml
42 42
      <scope>runtime</scope>
43 43
    </dependency>
44 44
    <dependency>
45
      <groupId>commons-collections</groupId>
46
      <artifactId>commons-collections</artifactId>
47
      <scope>runtime</scope>
48
    </dependency>
49
    <dependency>
50 45
      <groupId>commons-pool</groupId>
51 46
      <artifactId>commons-pool</artifactId>
52 47
      <scope>runtime</scope>

Also available in: Unified diff