The first config doesn't work, that should be something like:
<set-property property="connectionProperties" value="autoReconnect=true" />


but most people use your second solution (the url version)

-- Dirk

Sanjeet Joshi wrote:

Hi,

I am facing a problem with Connections to the database.

Here is the development environment in short:

Struts, Jsp, Servlets and MySQL 4.1
I am using DBCP connection pooling.  The datasource configuration is
in struts-config.xml file. I am using container managed security for
authentication.

I get EOFException when I try to login (or access the db for any other
purpose). This happens only after a long period of db inactivity.
Otherwise everything works fine.

When I searched for a solution, I found out that MySQL closes all
inactive connections after 8 hours. I also found out that setting a
MySQL attribute autoReconnect=true solves this. I tried setting it
along with my datasource config in struts-config.xml as follows:

<data-sources>
                <data-source key="xyz" 
type="org.apache.commons.dbcp.BasicDataSource">
                        <set-property property="driverClassName" 
value="com.mysql.jdbc.Driver" />
                        <set-property property="url" 
value="jdbc:mysql://localhost:3306/xyz" />
                        <set-property property="autoReconnect" value="true" />
                        <set-property property="username" value="***" />
                        <set-property property="password" value="***" />
                </data-source>
</data-sources>

Is this the correct way of setting autoReconnect to true? Some
solutions suggested setting it along with the url i.e. like

<set-property property="url"
value="jdbc:mysql://localhost:3306/xyz?autoReconnect=true" />

Which of these is correct?

To test this solution I tried to reduce the wait_timeout and
interactive_timeout (both MySQL variables) from 8 hours to one minute.
The connections were closed after a minutes inactivity. But my webapp
worked absolutely fine (without autoReconnect="true") So I could not
get EOFException on my development machine.

Is there anyone who has faced this problem and solved it? Any Pointers
to any reading material about this?

Any help is appreciated.

Thanks in advance.
Sanjeet

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to