You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Jörg Linke <jo...@hanse.net> on 2005/06/17 13:02:43 UTC

MySQL error using connection pool

Hi,

I'm using Struts 1.0 and have defined two data sources in the
struts-config.xml:
  <data-sources>
    <data-source key="BuhhKursDB">
      <set-property property="autoCommit" value="false" />
      <set-property property="description" value="MySQL Data Source
Configuration" />
      <set-property property="driverClass" value="org.gjt.mm.mysql.Driver"
/>
      <set-property property="maxCount" value="4" />
      <set-property property="minCount" value="2" />
      <set-property property="url" value="jdbc:mysql://localhost/buhhkurse"
/>
      <set-property property="user" value="buhhwebapp" />
      <set-property property="password" value="AmEsadS" />
      <set-property property="defaultReadOnly" value="true" />
      <set-property property="validationQuery" value="SELECT COUNT(*) FROM
seminar" />
      <set-property property="maxActive" value="1" />
    </data-source>
    <data-source key="BuhhStatsDB">
      <set-property property="autoCommit" value="true" />
      <set-property property="description" value="MySQL DB mit den
Statistiken" />
      <set-property property="driverClass" value="org.gjt.mm.mysql.Driver"
/>
      <set-property property="maxCount" value="4" />
      <set-property property="minCount" value="2" />
      <set-property property="url" value="jdbc:mysql://localhost/buhhstats"
/>
      <set-property property="user" value="buhhwebapp" />
      <set-property property="password" value="AmEsadS" />
      <set-property property="defaultReadOnly" value="true" />
      <set-property property="validationQuery" value="SELECT COUNT(*) FROM
zugriffe" />
    </data-source>
  </data-sources>

I'm using these data sources in my action servlet in the following way:

try {
         dataSourceA = (DataSource)servlet.findDataSource("BuhhKursDB");
         dataSourceB = (DataSource)servlet.findDataSource("BuhhStatsDB");

         kursDbConn = dataSourceA.getConnection();
         statsDbConn = dataSourceB.getConnection();
         fillDatumDatenbestand(kursForm, kursDbConn);
	   ....
}

  public void fillDatumDatenbestand(KurssucheForm kursForm, Connection
dbConn) {
    String sqlQuery = null;
    ResultSet rs = null;
    Statement stmt;
    sqlQuery =	"SELECT Max(Updatedatum) FROM updates";
    try{
      stmt = dbConn.createStatement();
      rs = stmt.executeQuery(sqlQuery);
      java.sql.Date updateDatum = null;

      if (rs != null) {
        while (rs.next()) {
          updateDatum = rs.getDate(1);
        }
        String datum = updateDatum.toString();
        kursForm.setDatenbestandJahr(datum.substring(0, 4));
        kursForm.setDatenbestandMonat(datum.substring(5, 7));
      }
    }catch(Exception e){
      e.printStackTrace();
    }
  }

Everything is working fine, until the web application idles for a longer
time.
Then the following error occures:

Connection was closed due to the following exception:

** BEGIN NESTED EXCEPTION **

java.sql.SQLException
MESSAGE: Communication link failure: java.io.EOFException, underlying cause:
null

** BEGIN NESTED EXCEPTION **

java.io.EOFException

STACKTRACE:

java.io.EOFException
	at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1394)
	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1538)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1929)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
	at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1224)
	at com.mysql.jdbc.Connection.execSQL(Connection.java:2248)
	at com.mysql.jdbc.Connection.execSQL(Connection.java:2196)
	at com.mysql.jdbc.Statement.executeQuery(Statement.java:1163)
	at
de.jlsolutions.webapps.buhh.PrepareKurssucheAction.fillDatumDatenbestand(Pre
pareKurssucheAction.java:118)
	at
de.jlsolutions.webapps.buhh.PrepareKurssucheAction.perform(PrepareKurssucheA
ction.java:56)

Has anybody an idea what is wrong?

Thanks,
Joe


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org