Problema con pool de conexiones

wakeup
09 de Julio del 2005
Trabajo con struts.
Tengo una pagina que tarda bastantes segundos en cargar ya que hace muchas consultas a base de datos. Al ejecutarla nunca da problemas pero si la lanzo desde dos navegadores al mismo tiempo casi siempre casca dando uno de estos dos errores aleatoriamente.
java.sql.SQLException: No operations allowed after connection closed.
java.sql.SQLException: Operation not allowed after ResultSet closed.

Usando mysql-connector-java-3.1.7-bin.jar

Usando un pool de conexiones.
Configuraci贸n de la BD
<data-source type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="driverClassName" value="org.gjt.mm.mysql.Driver" />
<set-property property="url" value="jdbc:mysql://localhost:3306/supervisiondb" />
<set-property property="username" value="acastro" />
<set-property property="password" value="acastro" />
<set-property property="maxActive" value="30" />
<set-property property="maxIdle" value="5" />
<set-property property="minIdle" value="2" />
<set-property property="minEvictableIdleTimeMillis" value="20000" />
<set-property property="timeBetweenEvictionRunsMillis" value="60000" />
<set-property property="maxWait" value="15000" />
<set-property property="defaultAutoCommit" value="true" />
<set-property property="defaultReadOnly" value="false" />
<set-property property="validationQuery" value="SELECT * FROM CLIENTES" />
<set-property property="testOnBorrow" value="true" />
<set-property property="testWhileIdle" value="true" />
<set-property property="removeAbandoned" value="true" />
<set-property property="removeAbandonedTimeout" value="60" />
<set-property property="logAbandoned" value="true" />
</data-source>


Si os hace falta mas informaci贸n avisarme.
muchas graciasss

http://hhdirecto.webcindario.com

jordi
09 de Julio del 2005
public static Connection getConnection() throws SQLException {

long now = System.currentTimeMillis();
lastGetConnectionTime = now;
// now check if we have not close all connections to refresh
// after MINUTES_BETWEEN_REFRESH minutes, then will do it now
if (now - lastCloseAllConnectionsTime > DateUtil.MINUTE * minutesBetweenRefresh) {
boolean isBalance = closeAllConnections();
if (isBalance == false) {
try {
// wait for the checked-out connections to be returned and closed
Thread.sleep(2000);
log.debug("DBUtils: sleep 2 seconds for checked-out connections to returned and closed.");
} catch (Exception ex) { }
}
}

Connection conection = null;


if (dataSource != null) {
conection = dataSource.getConnection();
}



if (conection == null) {
throw new SQLException("DBUtil: Cannot get connection from Connection Pool.");
}
return conection;
}

rzambran
09 de Julio del 2005
Hola.. sabes que tengo el mismo problema.. porfavor si tienes una soluci貌n avisame.

Gracias