Index: trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/resources/org/gvsig/postgresql/dal/PostgreSQLParameters.xml
===================================================================
--- trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/resources/org/gvsig/postgresql/dal/PostgreSQLParameters.xml	(revision 432)
+++ trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/resources/org/gvsig/postgresql/dal/PostgreSQLParameters.xml	(revision 433)
@@ -23,6 +23,10 @@
           defaultValue="false" group="Basic">
           <description>Use SSL connetion</description>
         </field>
+        <field name="maxIdle" type="integer" mandatory="false"
+          defaultValue="8" group="Advanced">
+          <description>The maximum number of connections that can remail idle in the pool.</description>
+        </field>
       </fields>
     </class>
 
Index: trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLHelper.java
===================================================================
--- trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLHelper.java	(revision 432)
+++ trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLHelper.java	(revision 433)
@@ -7,6 +7,7 @@
 import java.util.ArrayList;
 import java.util.List;
 import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.commons.dbcp.BasicDataSourceFactory;
 import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.gvsig.fmap.dal.DataTypes;
@@ -25,7 +26,7 @@
 import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory;
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCHelperBase;
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
-import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSRSsBase;
+import org.gvsig.fmap.dal.store.jdbc2.spi.SRSSolverBase;
 import org.gvsig.fmap.geom.Geometry;
 import org.gvsig.fmap.geom.aggregate.MultiLine;
 import org.gvsig.fmap.geom.aggregate.MultiPoint;
@@ -80,9 +81,74 @@
             if (this.dataSource == null) {
                 this.dataSource = this.createDataSource();               
             }
-            Connection conn = this.dataSource.getConnection();
+            if( logger.isDebugEnabled() ) {
+                logger.debug("getConnection:\n" + getStatusInformation());
+            }
+            Connection conn;
+            try {
+                conn = this.dataSource.getConnection();
+            } catch(Throwable ex) {
+                logger.debug("Error getting connection from pool.",ex);
+                throw ex;
+            }
+            if( logger.isDebugEnabled() ) {
+                logger.debug("Created connection: {}\n  NumActive: {}\n  NumIdle: {}",
+                    new Object[] {
+                        conn.hashCode(), 
+                        this.dataSource.getNumActive(),
+                        this.dataSource.getNumIdle()
+                    }
+                );
+            }
             return conn;
         }
+        
+        public void closeConnection(Connection connection) {
+            if( connection != null ) {
+                int connectionId = connection.hashCode();
+                try {
+                    connection.close();
+                } catch(Throwable ex) {
+                    logger.warn("Can't close connection.", ex);
+                }
+                if( logger.isDebugEnabled() ) {
+                    Boolean isClosed;
+                    try {
+                        isClosed = connection.isClosed();
+                    } catch(Throwable th) {
+                        isClosed = null;
+                    }
+                    logger.debug("Closed connection: {}\n  isClosed: {}\n  NumActive: {}\n  NumIdle: {}",
+                        new Object[] {
+                            connectionId, 
+                            isClosed,
+                            this.dataSource.getNumActive(),
+                            this.dataSource.getNumIdle()
+                        }
+                    );
+                }
+           } else if( logger.isDebugEnabled() ) {
+               logger.debug("Close connection: null");
+           }
+        }
+        
+        public String getStatusInformation() {
+            StringBuilder builder = new StringBuilder();
+            builder.append("BasicDataSource pool status:\n");
+            builder.append("  Connection URL: '").append(this.dataSource.getUrl()).append("'\n");
+            if( this.dataSource.getInitialSize()>0 ) {
+                builder.append("  InitialSize: ").append(this.dataSource.getInitialSize()).append(" (The initial number of connections that are created when the pool is started)\n");
+            }
+            if( this.dataSource.isPoolPreparedStatements() ) {
+                builder.append("  PoolPreparedStatements: ").append(this.dataSource.isPoolPreparedStatements()).append("\n");
+                builder.append("  MaxOpenPreparedStatements: ").append(this.dataSource.getMaxOpenPreparedStatements()).append(" (The maximum number of open statements that can be allocated from the statement pool at the same time, or non-positive for no limit)\n");
+            }
+            builder.append("  MaxActive: ").append(this.dataSource.getMaxActive()).append(" (The maximum number of active connections that can be allocated from this pool at the same time)\n");
+            builder.append("  MaxIdle: ").append(this.dataSource.getMaxIdle()).append(" (The maximum number of connections that can remain idle in the pool)\n");
+            builder.append("  NumActive:").append(this.dataSource.getNumActive()).append(" (the current number of active connections)\n");
+            builder.append("  NumIdle:").append(this.dataSource.getNumIdle()).append(" (the current number of idle connections)\n");
+            return builder.toString();
+        }
 
         private BasicDataSource createDataSource() throws SQLException {
             if (!this.isRegistered()) {
@@ -91,6 +157,7 @@
             PostgreSQLConnectionParameters params = connectionParameters;
 
             BasicDataSource ds = new BasicDataSource();
+            ds.setMaxIdle(params.getMaxIdle());
             ds.setDriverClassName(params.getJDBCDriverClassName());
             if( params.getUseSSL() ) {
                 String s = BooleanUtils.toStringTrueFalse(params.getUseSSL());
@@ -134,7 +201,7 @@
    
     public PostgreSQLHelper(JDBCConnectionParameters connectionParameters) {
         super(connectionParameters);
-        this.srss = new JDBCSRSsBase(this);
+        this.srssolver = new SRSSolverBase(this);
     }
 
     @Override
@@ -148,7 +215,14 @@
             throw new AccessResourceException(PostgreSQLLibrary.NAME, ex);
         }
     }
+
+    @Override
+    public void closeConnection(Connection connection) {
+         this.connectionProvider.closeConnection(connection);
+    }
     
+    
+    
     @Override
     public PostgreSQLConnectionParameters getConnectionParameters() {
         return (PostgreSQLConnectionParameters) super.getConnectionParameters();
Index: trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/operations/PostgreSQLFetchFeatureTypeOperation.java
===================================================================
--- trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/operations/PostgreSQLFetchFeatureTypeOperation.java	(revision 432)
+++ trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/operations/PostgreSQLFetchFeatureTypeOperation.java	(revision 433)
@@ -18,6 +18,7 @@
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
+import org.gvsig.fmap.dal.store.jdbc2.spi.SRSSolver;
 import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureTypeOperation;
 import org.gvsig.fmap.geom.Geometry;
 import org.gvsig.fmap.geom.GeometryLocator;
@@ -125,7 +126,8 @@
                 attr.setGeometryType(gt);
             }
             if( !StringUtils.isEmpty(srsid) ) {
-                attr.setSRS(this.helper.getProjectionFromDatabaseCode(srsid));
+                SRSSolver srssolver = this.helper.getSRSSolver();
+                attr.setSRS(srssolver.getProjection(this.getConnection(),srsid));
             }
         } catch (Exception ex) {
             logger.debug("Can't get geometry type and srs from column '"+attr.getName()+"'.",ex);
Index: trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLStoreParameters.java
===================================================================
--- trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLStoreParameters.java	(revision 432)
+++ trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLStoreParameters.java	(revision 433)
@@ -52,6 +52,11 @@
         return this.helper.getUseSSL();
     }
 
+    @Override
+    public int getMaxIdle() {
+        return this.helper.getMaxIdle();
+    }
+
     public void setUseSSL(boolean v) {
         this.helper.setUseSSL(v);
     }
Index: trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLConnectionParameters.java
===================================================================
--- trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLConnectionParameters.java	(revision 432)
+++ trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLConnectionParameters.java	(revision 433)
@@ -6,6 +6,9 @@
 
 public interface PostgreSQLConnectionParameters extends JDBCConnectionParameters, DBParameters {
 	public static final String USESSL_PARAMTER_NAME = "UseSSL";
+	public static final String MAXIDLE_PARAMTER_NAME = "maxIdle";
 
-	public boolean getUseSSL();    
+	public boolean getUseSSL();   
+    
+    public int getMaxIdle();
 }
Index: trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLConnectionParametersHelper.java
===================================================================
--- trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLConnectionParametersHelper.java	(revision 432)
+++ trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLConnectionParametersHelper.java	(revision 433)
@@ -52,6 +52,9 @@
         ((DataParameters)this.parameters).setDynValue(name,value);
     }
     
+    public int getMaxIdle() {
+        return (int) this.getDynValue(PostgreSQLConnectionParameters.MAXIDLE_PARAMTER_NAME);
+    }
 
     public boolean getUseSSL() {
         return (boolean) this.getDynValue(PostgreSQLConnectionParameters.USESSL_PARAMTER_NAME);
Index: trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLNewStoreParameters.java
===================================================================
--- trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLNewStoreParameters.java	(revision 432)
+++ trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLNewStoreParameters.java	(revision 433)
@@ -56,6 +56,11 @@
         return this.helper.getUseSSL();
     }
 
+    @Override
+    public int getMaxIdle() {
+        return this.helper.getMaxIdle();
+    }
+
     public void setUseSSL(boolean v) {
         this.helper.setUseSSL(v);
     }
Index: trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLServerExplorerParameters.java
===================================================================
--- trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLServerExplorerParameters.java	(revision 432)
+++ trunk/org.gvsig.postgresql/org.gvsig.postgresql.provider/src/main/java/org/gvsig/postgresql/dal/PostgreSQLServerExplorerParameters.java	(revision 433)
@@ -66,6 +66,11 @@
         return this.helper.getUseSSL();
     }
 
+    @Override
+    public int getMaxIdle() {
+        return this.helper.getMaxIdle();
+    }
+
     public void setUseSSL(boolean v) {
         this.helper.setUseSSL(v);
     }
