Revision 41880

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCHelper.java
34 34
import java.util.Arrays;
35 35
import java.util.Date;
36 36
import java.util.List;
37
import java.util.logging.Level;
37 38
import org.apache.commons.lang3.StringUtils;
38 39

  
39 40
import org.cresques.cts.IProjection;
......
139 140
            return st.executeUpdate();
140 141
        }
141 142
        
143
        public void closeConnection(Connection connection) {
144
            this.getResource().closeConnection(connection);
145
        }
142 146
        
147
        public void execute(String sql) throws JDBCExecuteSQLException {
148
            try {
149
                Connection conn = this.getConnection();
150
                Statement st = conn.createStatement();
151
                JDBCHelper.execute(st, sql);            
152
                this.closeConnection(conn);
153
            } catch (Exception ex) {
154
               throw new JDBCExecuteSQLException(sql, ex);
155
            }
156
        }
157
        
143 158
	protected void initializeResource() throws InitializeException {
144 159
		ResourceManagerProviderServices manager = (ResourceManagerProviderServices) DALLocator
145 160
				.getResourceManager();
......
324 339
					throw e;
325 340

  
326 341
				} finally {
327
					try {
328
						if (conn != null) {
329
							conn.close();
330
						}
331
					} catch (Exception e1) {
332
						logger.error("Exception on close connection", e1);
333
					}
334
					// this.end();
342
                                    closeConnection(conn);
335 343
				}
336 344
			}
337 345
		});
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCResource.java
98 98
	public Connection getJDBCConnection() throws AccessResourceException {
99 99
		return (Connection) get();
100 100
	}
101
        
102
        public void closeConnection(Connection connection) {
103
            try {
104
                logger.debug("before-close connection"+ this.getStatusInformation());
105
                connection.close();
106
                logger.debug("after close connection "+ this.getStatusInformation());
107
            } catch (Exception ex) {
108
                logger.warn("Problems closing connection.",ex);
109
            }            
110
        }
101 111

  
102 112
	private void debugPoolStatus(String src) {
103
		if (logger.isDebugEnabled() && dataSource instanceof BasicDataSource) {
104
			BasicDataSource ds = (BasicDataSource) dataSource;
105
			logger.debug(src + "  actives:" + ds.getNumActive() + "("
106
					+ ds.getMaxActive() + ") idle:" + ds.getNumIdle() + "("
107
					+ ds.getMaxIdle() + ")");
113
		if (logger.isDebugEnabled() ) {
114
			logger.debug(src + "  " + this.getStatusInformation());
108 115
		}
109

  
110 116
	}
117
        
118
        public String getStatusInformation() {
119
		if ( !(dataSource instanceof BasicDataSource) ) {
120
                    return "Connected: " + this.isConnected();
121
                }
122
        	BasicDataSource ds = (BasicDataSource) dataSource;
123
                String s = "Connected: " + this.isConnected() + ", " +
124
                        "actives: "+ ds.getNumActive() + "/"+ ds.getMaxActive() + ", " + 
125
                        "idle: " + ds.getNumIdle() + "/"+ ds.getMaxIdle() ;
126
                return s;
127
        }
111 128

  
112 129
	protected synchronized Object getTheConnection() throws DataException {
113 130
		try {
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCAppender.java
69 69
        } catch (SQLException ex) {
70 70
            throw new PerformEditingException(this.getSourceId().toString(), ex);
71 71
        } finally {
72
            this.provider.getHelper().closeConnection(this.connection);
72 73
            this.connection = null;
73 74
            this.provider.getHelper().getResource().endUse();
74 75
        }
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.jdbc/src/main/java/org/gvsig/exportto/swing/prov/jdbc/ExporrtoJDBCService.java
191 191
            );
192 192

  
193 193
            if (this.options.canCreatetable()) {
194
                logger.debug("Creating table");
194 195
                taskStatus.message("Creating table");
195 196
                this.createTable(explorer);
196 197
            }
......
222 223
                sourceGeometryIndex = sourceFeatureType.getDefaultGeometryAttributeIndex();
223 224
            }
224 225
            
226
            logger.debug("Inserting rows");
225 227
            taskStatus.message("Inserting rows");
226 228
            it = featureSet.fastIterator();
227 229
            while (it.hasNext()) {
......
317 319
            target.finishEditing();
318 320

  
319 321
            if (this.options.getUpdateTableStatistics()) {
322
                logger.debug("Updating statistics");
320 323
                taskStatus.message("Updating statistics");
321 324
                explorer.updateTableStatistics(openParams.tableID());
322 325
            }
326
            logger.debug("finish");
323 327

  
324 328
            if (exporttoServiceFinishAction != null) {
325 329
                exporttoServiceFinishAction.finished(

Also available in: Unified diff