Revision 63 trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/fmap/dal/store/postgresql/PostgreSQLResource.java

View differences:

PostgreSQLResource.java
39 39
import org.gvsig.fmap.dal.store.jdbc.JDBCResource;
40 40
import org.gvsig.fmap.dal.store.jdbc.JDBCResourceParameters;
41 41
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCDriverClassNotFoundException;
42
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCException;
42 43
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
43 44
import org.slf4j.Logger;
44 45
import org.slf4j.LoggerFactory;
......
61 62
		return MessageFormat.format("PostgreSQLResource({0},{1})",
62 63
				new Object[] { params.getUrl(),params.getUser() });
63 64
	}
65
        
66
        public String toString() {
67
            try {
68
                return this.getName();
69
            } catch(Exception ex) {
70
                return super.toString();
71
            }
72
        }
64 73

  
65 74
	protected void connectToDB() throws DataException {
66 75
		if (this.dataSource != null) {
......
181 190

  
182 191
	}
183 192

  
193
        private static class CanGetConnectionException extends JDBCSQLException {
194
            public CanGetConnectionException(String datasource, SQLException cause) {
195
                super("Can't get a connection to the data source (%(datasource))", cause, "_CanGetConnectionException", 0);
196
                setValue("datasource", datasource);
197
            }
198
        }
199
    
184 200
	protected synchronized Object getTheConnection() throws DataException {
185 201
		try {
186 202
			Object conn = this.dataSource.getConnection();
187 203
			logPoolStatus("getTheConnection");
188 204
			return conn;
189 205
		} catch (SQLException e) {
190
			throw new JDBCSQLException(e);
206
			throw new CanGetConnectionException(this.toString(),e);
191 207
		}
192 208
	}	
193 209

  

Also available in: Unified diff