Revision 294

View differences:

trunk/org.gvsig.postgresql/pom.xml
11 11
  <parent>
12 12
      <groupId>org.gvsig</groupId>
13 13
      <artifactId>org.gvsig.desktop</artifactId>
14
      <version>2.0.148</version>
14
      <version>2.0.158</version>
15 15
  </parent>
16 16

  
17 17
  <url>https://devel.gvsig.org/redmine/projects/gvsig-postgresql</url>
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/resources/org/gvsig/fmap/dal/store/postgresql/PostgreSQLParameters.xml
15 15
          defaultValue="5432" group="Connection">
16 16
          <description></description>
17 17
        </field>
18
        <field name="host" type="string" mandatory="false" 
19
            defaultValue="127.0.0.1" group="Connection">
20
          <description></description>
21
        </field>
18 22
        <field name="UseSSL" type="boolean" mandatory="false"
19 23
          defaultValue="false" group="Basic">
20 24
          <description>Use SSL connetion</description>
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorerFactory.java
1
package org.gvsig.fmap.dal.store.postgresql;
2

  
3
import org.gvsig.fmap.dal.DataServerExplorerParameters;
4
import org.gvsig.fmap.dal.exception.InitializeException;
5
import org.gvsig.fmap.dal.spi.AbstractDataServerExplorerFactory;
6
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
7

  
8
public class PostgreSQLServerExplorerFactory extends AbstractDataServerExplorerFactory {
9

  
10
    public PostgreSQLServerExplorerFactory() {
11
        super(
12
                PostgreSQLLibrary.NAME,
13
                "PostgreSQL+PostGIS server"
14
        );
15
    }
16

  
17
    @Override
18
    public PostgreSQLServerExplorer create(
19
            DataServerExplorerParameters parameters,
20
            DataServerExplorerProviderServices providerServices
21
    ) throws InitializeException {
22
        PostgreSQLServerExplorer explorer = new PostgreSQLServerExplorer(
23
                (PostgreSQLServerExplorerParameters) parameters,
24
                providerServices
25
        );
26
        return explorer;
27
    }
28

  
29
    @Override
30
    public PostgreSQLServerExplorerParameters createParameters() {
31
        return new PostgreSQLServerExplorerParameters();
32
    }
33

  
34
}
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLStoreProviderFactory.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.dal.store.postgresql;
24

  
25
import org.slf4j.Logger;
26
import org.slf4j.LoggerFactory;
27

  
28
import org.gvsig.fmap.dal.DataParameters;
29
import org.gvsig.fmap.dal.exception.InitializeException;
30
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProviderFactory;
31
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
32

  
33
public class PostgreSQLStoreProviderFactory 
34
    extends AbstractFeatureStoreProviderFactory 
35
    {
36

  
37
    private static final Logger logger = LoggerFactory.getLogger(PostgreSQLStoreProviderFactory.class);
38

  
39
    protected PostgreSQLStoreProviderFactory() {
40
        super(
41
                PostgreSQLLibrary.NAME, 
42
                "PostgreSQL+PostGIS store"
43
        );
44
    }
45

  
46
    @Override
47
    public PostgreSQLStoreProvider createProvider(DataParameters parameters,
48
            DataStoreProviderServices providerServices)
49
            throws InitializeException {
50
        return new PostgreSQLStoreProvider((PostgreSQLStoreParameters) parameters, providerServices);
51
    }
52

  
53
    @Override
54
    public PostgreSQLStoreParameters createParameters() {
55
        return new PostgreSQLStoreParameters();
56
    }
57

  
58
}
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLLibrary.java
39 39

  
40 40
public class PostgreSQLLibrary extends AbstractLibrary {
41 41

  
42
	static String DEFAULT_JDCB_DRIVER_NAME = "org.postgresql.Driver";
42
    static String DEFAULT_JDCB_DRIVER_NAME = "org.postgresql.Driver";
43
    public static final String NAME = "PostgreSQL";
43 44

  
44 45
    @Override
45 46
    public void doRegistration() {
......
116 117
				.getDataManager();
117 118
		
118 119
		if (!dataman.getStoreProviders().contains(PostgreSQLStoreProvider.NAME)) {
119
			dataman.registerStoreProvider(PostgreSQLStoreProvider.NAME,
120
					PostgreSQLStoreProvider.class,
121
					PostgreSQLStoreParameters.class);
120
			dataman.registerStoreProviderFactory(
121
                                new PostgreSQLStoreProviderFactory()
122
                        );
122 123
		}
123 124
		
124 125
		if (!dataman.getExplorerProviders().contains(
125 126
				PostgreSQLStoreProvider.NAME)) {
126
			dataman.registerExplorerProvider(PostgreSQLServerExplorer.NAME,
127
					PostgreSQLServerExplorer.class,
128
					PostgreSQLServerExplorerParameters.class);
127
			dataman.registerServerExplorerFactory(
128
                                new PostgreSQLServerExplorerFactory()
129
                        );
129 130
		}
130 131
		if( ex!=null ) {
131 132
			throw ex;
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLResource.java
20 20
*
21 21
*/
22 22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 IVER T.I   {{Task}}
26
*/
27

  
28 23
package org.gvsig.fmap.dal.store.postgresql;
29 24

  
30
import java.sql.SQLException;
31
import java.text.MessageFormat;
32

  
33 25
import javax.sql.DataSource;
34

  
35 26
import org.apache.commons.dbcp.BasicDataSource;
36
import org.gvsig.fmap.dal.exception.DataException;
37 27
import org.gvsig.fmap.dal.exception.InitializeException;
38
import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
39 28
import org.gvsig.fmap.dal.store.jdbc.JDBCResource;
40 29
import org.gvsig.fmap.dal.store.jdbc.JDBCResourceParameters;
41 30
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCDriverClassNotFoundException;
42
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCException;
43
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
44 31
import org.slf4j.Logger;
45 32
import org.slf4j.LoggerFactory;
46 33

  
47 34
public class PostgreSQLResource extends JDBCResource {
48 35
	
49
	final static private Logger logger = LoggerFactory
50
			.getLogger(PostgreSQLResource.class);
36
	final static private Logger logger = LoggerFactory.getLogger(PostgreSQLResource.class);
51 37

  
52 38
	public final static String NAME = "PostgreSQLResource";
53 39
	public static final String DESCRIPTION = "PostgreSQL Connection";
54 40

  
55
	public PostgreSQLResource(PostgreSQLResourceParameters parameters)
56
			throws InitializeException {
57
		super(parameters);
41
	public PostgreSQLResource(
42
                PostgreSQLResourceParameters parameters
43
            ) throws InitializeException {
44
            super(parameters);
58 45
	}
46
        
59 47

  
60
	public String getName() throws AccessResourceException {
61
		PostgreSQLResourceParameters params = (PostgreSQLResourceParameters) this.getParameters();
62
		return MessageFormat.format("PostgreSQLResource({0},{1})",
63
				new Object[] { params.getUrl(),params.getUser() });
64
	}
65
        
66
        public String toString() {
67
            try {
68
                return this.getName();
69
            } catch(Exception ex) {
70
                return super.toString();
48
    /**
49
     * Registra/Carga el driver de JDBC.
50
     * 
51
     * Debe ser sobreescrita en cada proveedor de datos para asegurar que se
52
     * tegna acceso al driver.
53
     * 
54
     * @throws InitializeException 
55
     */
56
    @Override
57
    protected void registerJDBCDriver() throws InitializeException {
58
        String className = this.getParameters().getJDBCDriverClassName();
59
        if (className == null) {
60
            return;
61
        }
62
        try {
63
            Class theClass = Class.forName(className);
64
            if (theClass == null) {
65
                throw new JDBCDriverClassNotFoundException(this.getName(), className);
71 66
            }
67
        } catch (Exception e) {
68
            throw new InitializeException(e);
72 69
        }
70
    }
73 71

  
74
	protected void connectToDB() throws DataException {
75
		if (this.dataSource != null) {
76
			return;
77
		}
78
		JDBCResourceParameters jdbcParams = (JDBCResourceParameters) this
79
				.getParameters();
80
		BasicDataSource dataSource = new BasicDataSource();
81
		dataSource.setDriverClassName(jdbcParams.getJDBCDriverClassName());
82
		dataSource.setUsername(jdbcParams.getUser());
83
		dataSource.setPassword(jdbcParams.getPassword());
84
		dataSource.setUrl(jdbcParams.getUrl());
72
    /**
73
     * Crea el JDBC DataSource a partir de la informacion de los parametros
74
     * del recurso.
75
     * 
76
     * Debe ser sobreescrita en cada proveedor de datos para asegurar que se
77
     * tenga acceso al driver.
78
     * 
79
     * @return 
80
     */
81
    @Override
82
    protected DataSource createDataSource() {
83
        JDBCResourceParameters jdbcParams = this.getParameters();
84
        BasicDataSource dataSource = new BasicDataSource();
85
        dataSource.setDriverClassName(jdbcParams.getJDBCDriverClassName());
86
        dataSource.setUsername(jdbcParams.getUser());
87
        dataSource.setPassword(jdbcParams.getPassword());
88
        dataSource.setUrl(jdbcParams.getUrl());
85 89

  
86
		dataSource.setMaxWait(60L * 1000); // FIXME
90
        dataSource.setMaxWait(60L * 1000); // FIXME
87 91

  
88
		// FIXME Set Pool parameters:
89
		/*
90
		dataSource.setMaxActive(maxActive);
91
		dataSource.setMaxIdle(maxActive);
92
		dataSource.setMaxOpenPreparedStatements(maxActive);
93
		dataSource.setMaxWait(maxActive);
94
		dataSource.setInitialSize(initialSize);
95
		dataSource.setDefaultReadOnly(defaultReadOnly);
96
		dataSource.setDefaultTransactionIsolation(defaultTransactionIsolation);
97
		dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
98
		dataSource.setMinIdle(minIdle);
99
		dataSource.setTestOnBorrow(testOnBorrow);
100
		dataSource.setTestOnReturn(testOnReturn);
101
		dataSource.setTestWhileIdle(testOnReturn);
102
		dataSource
103
				.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
104

  
105
		dataSource.setAccessToUnderlyingConnectionAllowed(allow);
106
		dataSource.setLoginTimeout(seconds);
107
		dataSource.setLogWriter(out);
108
		*/
109

  
110
		this.dataSource = dataSource;
111
	}	
112
	protected void registerJDBCDriver() throws InitializeException {
113
		String className = ((JDBCResourceParameters) getParameters())
114
				.getJDBCDriverClassName();
115
		if (className == null) {
116
			return;
117
		}
118

  
119
		Class theClass = null;
120
		try {
121
			theClass = Class.forName(className);
122
		} catch (Exception e){
123
			throw new InitializeException(e);
124
		}
125
		if (theClass == null) {
126
			try {
127
				throw new JDBCDriverClassNotFoundException(this.getName(),
128
						className);
129
			} catch (AccessResourceException e) {
130
				throw new InitializeException(e);
131

  
132
			}
133
		}
134
	}
135
	
136
	protected DataSource createDataSource() {
137
		PostgreSQLResourceParameters jdbcParams = (PostgreSQLResourceParameters) this
138
				.getParameters();
139
		BasicDataSource dataSource = new BasicDataSource();
140
		dataSource.setDriverClassName(jdbcParams.getJDBCDriverClassName());
141
		dataSource.setUsername(jdbcParams.getUser());
142
		dataSource.setPassword(jdbcParams.getPassword());
143
		dataSource.setUrl(jdbcParams.getUrl());
144

  
145
		dataSource.setMaxWait(60L * 1000); // FIXME
146

  
147
		// FIXME Set Pool parameters:
148
		/*
149
		dataSource.setMaxActive(maxActive);
150
		dataSource.setMaxIdle(maxActive);
151
		dataSource.setMaxOpenPreparedStatements(maxActive);
152
		dataSource.setMaxWait(maxActive);
153
		dataSource.setInitialSize(initialSize);
154
		dataSource.setDefaultReadOnly(defaultReadOnly);
155
		dataSource.setDefaultTransactionIsolation(defaultTransactionIsolation);
156
		dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
157
		dataSource.setMinIdle(minIdle);
158
		dataSource.setTestOnBorrow(testOnBorrow);
159
		dataSource.setTestOnReturn(testOnReturn);
160
		dataSource.setTestWhileIdle(testOnReturn);
161
		dataSource
162
			.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
163

  
164
		dataSource.setAccessToUnderlyingConnectionAllowed(allow);
165
		dataSource.setLoginTimeout(seconds);
166
		dataSource.setLogWriter(out);
167
		 */
168
		return dataSource;
169
	}
170
	
171
	
172
	public boolean isConnected() {
173
		if (dataSource == null) {
174
			return false;
175
		}
176
		if (dataSource instanceof BasicDataSource) {
177
			return ((BasicDataSource) dataSource).getNumActive() > 0
178
					|| ((BasicDataSource) dataSource).getNumIdle() > 0;
179
		}
180
		return true;
181
	}	
182
	
183
	private void logPoolStatus(String src) {
184
		if (logger.isDebugEnabled() ) {
185
			logger.debug(src + "  " + this.getStatusInformation());
186
		}
187

  
188
	}
92
//                FIXME Set Pool parameters:
93
//		dataSource.setMaxActive(maxActive);
94
//		dataSource.setMaxIdle(maxActive);
95
//		dataSource.setMaxOpenPreparedStatements(maxActive);
96
//		dataSource.setMaxWait(maxActive);
97
//		dataSource.setInitialSize(initialSize);
98
//		dataSource.setDefaultReadOnly(defaultReadOnly);
99
//		dataSource.setDefaultTransactionIsolation(defaultTransactionIsolation);
100
//		dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
101
//		dataSource.setMinIdle(minIdle);
102
//		dataSource.setTestOnBorrow(testOnBorrow);
103
//		dataSource.setTestOnReturn(testOnReturn);
104
//		dataSource.setTestWhileIdle(testOnReturn);
105
//		dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
106
//
107
//		dataSource.setAccessToUnderlyingConnectionAllowed(allow);
108
//		dataSource.setLoginTimeout(seconds);
109
//		dataSource.setLogWriter(out);
110
        return dataSource;
111
    }
189 112
        
190
        public String getStatusInformation() {
191
		if ( !(dataSource instanceof BasicDataSource) ) {
192
                    return "Connected: " + this.isConnected();
193
                }
194
        	BasicDataSource ds = (BasicDataSource) dataSource;
195
                String s = "Connected: " + this.isConnected() + ", " +
196
                        "actives: "+ ds.getNumActive() + "/"+ ds.getMaxActive() + ", " + 
197
                        "idle: " + ds.getNumIdle() + "/"+ ds.getMaxIdle() ;
198
                return s;
199
        }
113
//
114
//	public String getName() throws AccessResourceException {
115
//		PostgreSQLResourceParameters params = (PostgreSQLResourceParameters) this.getParameters();
116
//		return MessageFormat.format("PostgreSQLResource({0},{1})",
117
//				new Object[] { params.getUrl(),params.getUser() });
118
//	}
119
//        
120
//        public String toString() {
121
//            try {
122
//                return this.getName();
123
//            } catch(Exception ex) {
124
//                return super.toString();
125
//            }
126
//        }
127
//
128
//	protected void connectToDB() throws DataException {
129
//		if (this.dataSource != null) {
130
//			return;
131
//		}
132
//		JDBCResourceParameters jdbcParams = (JDBCResourceParameters) this
133
//				.getParameters();
134
//		BasicDataSource dataSource = new BasicDataSource();
135
//		dataSource.setDriverClassName(jdbcParams.getJDBCDriverClassName());
136
//		dataSource.setUsername(jdbcParams.getUser());
137
//		dataSource.setPassword(jdbcParams.getPassword());
138
//		dataSource.setUrl(jdbcParams.getUrl());
139
//
140
//		dataSource.setMaxWait(60L * 1000); // FIXME
141
//
142
//		// FIXME Set Pool parameters:
143
//		/*
144
//		dataSource.setMaxActive(maxActive);
145
//		dataSource.setMaxIdle(maxActive);
146
//		dataSource.setMaxOpenPreparedStatements(maxActive);
147
//		dataSource.setMaxWait(maxActive);
148
//		dataSource.setInitialSize(initialSize);
149
//		dataSource.setDefaultReadOnly(defaultReadOnly);
150
//		dataSource.setDefaultTransactionIsolation(defaultTransactionIsolation);
151
//		dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
152
//		dataSource.setMinIdle(minIdle);
153
//		dataSource.setTestOnBorrow(testOnBorrow);
154
//		dataSource.setTestOnReturn(testOnReturn);
155
//		dataSource.setTestWhileIdle(testOnReturn);
156
//		dataSource
157
//				.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
158
//
159
//		dataSource.setAccessToUnderlyingConnectionAllowed(allow);
160
//		dataSource.setLoginTimeout(seconds);
161
//		dataSource.setLogWriter(out);
162
//		*/
163
//
164
//		this.dataSource = dataSource;
165
//	}	
166
//	protected void registerJDBCDriver() throws InitializeException {
167
//		String className = ((JDBCResourceParameters) getParameters())
168
//				.getJDBCDriverClassName();
169
//		if (className == null) {
170
//			return;
171
//		}
172
//
173
//		Class theClass = null;
174
//		try {
175
//			theClass = Class.forName(className);
176
//		} catch (Exception e){
177
//			throw new InitializeException(e);
178
//		}
179
//		if (theClass == null) {
180
//			try {
181
//				throw new JDBCDriverClassNotFoundException(this.getName(),
182
//						className);
183
//			} catch (AccessResourceException e) {
184
//				throw new InitializeException(e);
185
//
186
//			}
187
//		}
188
//	}
189
//	
190
//	protected DataSource createDataSource() {
191
//		PostgreSQLResourceParameters jdbcParams = (PostgreSQLResourceParameters) this
192
//				.getParameters();
193
//		BasicDataSource dataSource = new BasicDataSource();
194
//		dataSource.setDriverClassName(jdbcParams.getJDBCDriverClassName());
195
//		dataSource.setUsername(jdbcParams.getUser());
196
//		dataSource.setPassword(jdbcParams.getPassword());
197
//		dataSource.setUrl(jdbcParams.getUrl());
198
//
199
//		dataSource.setMaxWait(60L * 1000); // FIXME
200
//
201
//		// FIXME Set Pool parameters:
202
//		/*
203
//		dataSource.setMaxActive(maxActive);
204
//		dataSource.setMaxIdle(maxActive);
205
//		dataSource.setMaxOpenPreparedStatements(maxActive);
206
//		dataSource.setMaxWait(maxActive);
207
//		dataSource.setInitialSize(initialSize);
208
//		dataSource.setDefaultReadOnly(defaultReadOnly);
209
//		dataSource.setDefaultTransactionIsolation(defaultTransactionIsolation);
210
//		dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
211
//		dataSource.setMinIdle(minIdle);
212
//		dataSource.setTestOnBorrow(testOnBorrow);
213
//		dataSource.setTestOnReturn(testOnReturn);
214
//		dataSource.setTestWhileIdle(testOnReturn);
215
//		dataSource
216
//			.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
217
//
218
//		dataSource.setAccessToUnderlyingConnectionAllowed(allow);
219
//		dataSource.setLoginTimeout(seconds);
220
//		dataSource.setLogWriter(out);
221
//		 */
222
//		return dataSource;
223
//	}
224
//	
225
//	
226
//	public boolean isConnected() {
227
//		if (dataSource == null) {
228
//			return false;
229
//		}
230
//		if (dataSource instanceof BasicDataSource) {
231
//			return ((BasicDataSource) dataSource).getNumActive() > 0
232
//					|| ((BasicDataSource) dataSource).getNumIdle() > 0;
233
//		}
234
//		return true;
235
//	}	
236
//	
237
//	private void logPoolStatus(String src) {
238
//		if (logger.isDebugEnabled() ) {
239
//			logger.debug(src + "  " + this.getStatusInformation());
240
//		}
241
//
242
//	}
243
//        
244
//        public String getStatusInformation() {
245
//		if ( !(dataSource instanceof BasicDataSource) ) {
246
//                    return "Connected: " + this.isConnected();
247
//                }
248
//        	BasicDataSource ds = (BasicDataSource) dataSource;
249
//                String s = "Connected: " + this.isConnected() + ", " +
250
//                        "actives: "+ ds.getNumActive() + "/"+ ds.getMaxActive() + ", " + 
251
//                        "idle: " + ds.getNumIdle() + "/"+ ds.getMaxIdle() ;
252
//                return s;
253
//        }
254
//
255
//        
256
//
257
//        private static class CanGetConnectionException extends JDBCSQLException {
258
//            public CanGetConnectionException(String datasource, SQLException cause) {
259
//                super("Can't get a connection to the data source (%(datasource))", cause, "_CanGetConnectionException", 0);
260
//                setValue("datasource", datasource);
261
//            }
262
//        }
263
//    
264
//	protected synchronized Object getTheConnection() throws DataException {
265
//		try {
266
//			Object conn = this.dataSource.getConnection();
267
//			logPoolStatus("getTheConnection");
268
//			return conn;
269
//		} catch (SQLException e) {
270
//			throw new CanGetConnectionException(this.toString(),e);
271
//		}
272
//	}	
200 273

  
201
        
202

  
203
        private static class CanGetConnectionException extends JDBCSQLException {
204
            public CanGetConnectionException(String datasource, SQLException cause) {
205
                super("Can't get a connection to the data source (%(datasource))", cause, "_CanGetConnectionException", 0);
206
                setValue("datasource", datasource);
207
            }
208
        }
209
    
210
	protected synchronized Object getTheConnection() throws DataException {
211
		try {
212
			Object conn = this.dataSource.getConnection();
213
			logPoolStatus("getTheConnection");
214
			return conn;
215
		} catch (SQLException e) {
216
			throw new CanGetConnectionException(this.toString(),e);
217
		}
218
	}	
219

  
220 274
}
trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLServerExplorer.java
32 32
import java.sql.Connection;
33 33
import java.sql.SQLException;
34 34
import java.sql.Statement;
35
import java.text.MessageFormat;
35 36
import java.util.ArrayList;
36 37
import java.util.Iterator;
37 38
import java.util.List;
38 39
import java.util.logging.Level;
40
import org.apache.commons.lang3.StringUtils;
39 41

  
40 42
import org.gvsig.fmap.dal.DataStoreParameters;
41 43
import org.gvsig.fmap.dal.NewDataStoreParameters;
......
46 48
import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
47 49
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
48 50
import org.gvsig.fmap.dal.store.jdbc.JDBCHelper;
49
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer;
51
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerBase;
50 52
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
51 53
import org.gvsig.fmap.dal.store.jdbc.TransactionalAction;
52 54
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCExecuteSQLException;
......
58 60
 * @author jmvivo
59 61
 *
60 62
 */
61
public class PostgreSQLServerExplorer extends JDBCServerExplorer {
63
public class PostgreSQLServerExplorer extends JDBCServerExplorerBase {
62 64

  
63 65
    final static private Logger logger = LoggerFactory
64 66
            .getLogger(PostgreSQLServerExplorer.class);
......
232 234
        return x;
233 235
    }
234 236

  
235
    public void updateTableStatistics(String tableName) throws JDBCExecuteSQLException {
236
        String sql="";
237
        if( tableName.startsWith("\"") ) {
238
            sql = "VACUUM ANALYZE " + tableName ;
237
    @Override
238
    public void updateTableStatistics(String database, String schema, String table) throws JDBCExecuteSQLException {
239
        String sql = null;
240
        if( StringUtils.isEmpty(database) ) {
241
            if( StringUtils.isEmpty(schema) ) {
242
                sql = MessageFormat.format("VACUUM ANALIZE \"{0}\".\"{1}\".\"{2}\"", 
243
                        database, schema, table
244
                );
245
            }
246
        } else if( StringUtils.isEmpty(schema) ) {
247
            sql = MessageFormat.format("VACUUM ANALIZE \"{0}\".\"{1}\"", 
248
                    schema, table
249
            );
239 250
        } else {
240
            sql = "VACUUM ANALYZE \"" + tableName + "\"";
251
            sql = MessageFormat.format("VACUUM ANALIZE \"{0}\"", 
252
                    table
253
            );
241 254
        }
255
        if( sql == null ) {
256
            throw new IllegalArgumentException("Can't update statistics, identifier of table incorrect (database '"+database+"', schema '"+schema+"', table '"+table+"')");
257
        }
242 258
        this.getHelper().execute(sql);
243 259
    }
244 260

  

Also available in: Unified diff