Eric,

Eric Yin wrote:
> Hi,
> 
> I'm using tomcat5.5.2 and mysql5.0.27 and Connector/J 5.0.
> i'm doing the same thing as
> http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> and i got this error.

Where did you put mysql-connector-*.jar? I suspect that you have it in
your webapp's lib directory, but you need to have it in Tomcat's
server-wise common/lib directory.

Another note:

> url="jdbc:mysql://localhost:3306/p6120?autoReconnect=true"/>

Since you are using a DataSource which defaults to the Jakarta Commons
DBCP pool, you should remove the "autoReconnect=true" from your URL;
re-connection is handled by the DPCP library, so you /should be/ able to
safely remove this parameter. This feature is documented to be
undesirable as seen here:

http://dev.mysql.com/doc/refman/4.1/en/connector-j-reference-configuration-properties.html

For the lazy: (emphasis added by me)

"Should the driver try to re-establish stale and/or dead connections? If
enabled the driver will throw an exception for a queries issued on a
stale or dead connection, which belong to the current transaction, but
will attempt reconnect before the next query issued on the connection in
a new transaction. *The use of this feature is not recommended, because
it has side effects related to session state and data consistency when
applications don'thandle SQLExceptions properly, and is only designed to
be used when you are unable to configure your application to handle
SQLExceptions resulting from dead andstale connections properly*.
Alternatively, investigate setting the MySQL server variable
"wait_timeout"to some high value rather than the default of 8 hours."

-chris

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to