Hosung-Lee / log4jdbc

Automatically exported from code.google.com/p/log4jdbc
0 stars 0 forks source link

Sudden expect ion after turning on log4jdbc: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException #43

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
After i plugged log4jdbc into my connections, i started to see these messages 
in the error logs:

"2012-02-01 09:51:00 - ERROR ajp-8009-9 jdbc.sqltiming - 10. 
Connection.setAutoCommit(false)
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet 
successfully received from the server was 55,923,403 milliseconds ago.  The 
last packet sent successfully to the server was 55,923,415 milliseconds ago. is 
lonn
    ger than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using thee
     Connector/J connection property 'autoReconnect=true' to avoid this problem."

It basically repeats these messages in different classes: jdbc.sqlonly, 
jdbc.sqltiming and jdbc.audit.

I already have autoReconnect set to true. I suspect the problem is that 
log4jdbc is not respecting testOnBorrow=”true” validationQuery=”select 
1″

1/ Why did this error stop appearing after i enabled log4jdbc
2/ How can i avoid printing duplicate error messages

--Ricardo

Original issue reported on code.google.com by rvelo...@gmail.com on 1 Feb 2012 at 11:07

GoogleCodeExporter commented 8 years ago
this is my config on spring:

    <bean id="parentDataSource" class="org.apache.commons.dbcp.BasicDataSource" abstract="true">
        <property name="driverClassName" value="net.sf.log4jdbc.DriverSpy"/>        
        <property name="username" value="${db.username}" />
        <property name="password" value="${db.password}" />
        <property name="initialSize" value="5"/>
        <property name="validationQuery" value="select 1" />
        <property name="defaultAutoCommit" value="false" />
        <property name="maxActive" value="100" />
        <property name="maxIdle" value="10" />
        <property name="maxWait" value="15000" />
        <property name="removeAbandoned" value="true" />
        <property name="removeAbandonedTimeout" value="300" />
        <property name="testOnBorrow" value="true" />
    </bean> 

Original comment by rvelo...@gmail.com on 1 Feb 2012 at 11:37

GoogleCodeExporter commented 8 years ago
This is not a bug, rather it's designed to work this way. The exception is 
being thrown by the application.

It's probably a good idea to have an option to suppress logging of exceptions 
entirely-- but not something I will get around to adding any time soon.

You may want to create a feature request for specific change.

If you want to modify your copy of log4jdbc to suppress a specific SQL 
exception,  http://code.google.com/p/log4jdbc/source/detail?r=86  is an example 
of where it was done in another context. 

Original comment by arthur.b...@gmail.com on 2 Feb 2012 at 3:31

GoogleCodeExporter commented 8 years ago
What about the triplication of exception throwing in sqlonly, sqltiming and 
jdbc.audit? this is really bad for people that use spring and alerts on error 
logs

Original comment by rvelo...@gmail.com on 2 Feb 2012 at 6:05