You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nomen Nominus <ge...@outlook.com> on 2013/08/10 14:56:10 UTC

Issue with cannot open connection

Here is my problem. I have a very classical configuration where a webapp 

with some Hibernate code in it accesses a MySQL DB. Everything is 

installed in Tomcat 6. 
I even acquired c3p0 connection pooling with the following configuration:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>

<session-factory>

    <!-- Settings for MySql DB -->

    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>  

    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/myDB?autoReconnect=true</property>         
    <property name="hibernate.connection.username">myUsername</property>

    <property name="hibernate.connection.password">myPass</property>   

    <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>         
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="hibernate.connection.pool_size">5</property>         
    <property name="show_sql">true</property>   

    <property name="hibernate.c3p0.idle_test_period">1800</property> <!-- In seconds -->  

    <property name="hibernate.c3p0.min_size">5</property>

    <property name="hibernate.c3p0.max_size">20</property>

    <property name="hibernate.c3p0.timeout">2400</property>         
    <property name="hibernate.c3p0.max_statements">50</property>
    
</session-factory>

</hibernate-configuration>

After some time, ( around 60 secs ) Hibernate complains about dropped connections, the 

error message looks like this :

com.mysql.jdbc.CommunicationsException : Communications link failure The 

last packet successfully received from the server was
milliseconds ago. The last packet sent successfully to the server was 0 

milliseconds ago.

java.io.EOFException : Can not read response from server. Expected to 

read 4 bytes, read 0 bytes before connection was unexpectedly lost.


Refeshing the page once or twice usually fixes the problem.


Has anyone else encountered on this issue before, and if so, please help me. What could be possible solution to this resolution?

Thanks in advance.


 		 	   		  

RE: Issue with cannot open connection

Posted by Nomen Nominus <ge...@outlook.com>.
OK, Thiago! :))
Just for the final, I have managed to solve this by following:
My host operator had global wait_timeout set to around 60 secs, and since I didn't have local wait_timeout( the one set for my app( just append it to jdbc string ) ) it operated on global wait_timeout, and would throw cannot open connection after that interval, since my c3p0 settings were setup so high, and couldn't manage between.


so solution for this would have been:
c3p0 idle time around 300 ( less than wait timeout and c3p0 timeout )
c3p0 timeout 2400 ( less than wait_timeout, but higher than idle time )
wait_timeout( could be appended to jdbc as a string, and must be higher than c3p0 timeout and idle time )

If these formulations above should be applied, issue is gone.

> To: users@tapestry.apache.org
> Subject: Re: Issue with cannot open connection
> Date: Sat, 10 Aug 2013 17:27:07 -0300
> From: thiagohp@gmail.com
> 
> Guys, please don't continue this thread. This is a pure MySQL problem,  
> completely unrelated to Tapestry. Thank you. ;)
> 
> On Sat, 10 Aug 2013 15:54:14 -0300, Dmitry Gusev <dm...@gmail.com>  
> wrote:
> 
> > It may be that connection that is in the pool is stil open, but database
> > already closed it by timeout. You need to chek timeouts in the pool so  
> > that
> > it be less than in the database.
> >
> > On Saturday, August 10, 2013, Nomen Nominus wrote:
> >
> >> Here is my problem. I have a very classical configuration where a webapp
> >>
> >> with some Hibernate code in it accesses a MySQL DB. Everything is
> >>
> >> installed in Tomcat 6.
> >> I even acquired c3p0 connection pooling with the following  
> >> configuration:
> >>
> >> <?xml version="1.0" encoding="UTF-8"?>
> >>
> >> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate
> >> Configuration DTD//EN"
> >>    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
> >> <hibernate-configuration>
> >>
> >> <session-factory>
> >>
> >>     <!-- Settings for MySql DB -->
> >>
> >>     <property
> >> name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
> >>
> >>     <property
> >> name="hibernate.connection.url">jdbc:mysql://localhost:3306/myDB?autoReconnect=true</property>
> >>     <property name="hibernate.connection.username">myUsername</property>
> >>
> >>     <property name="hibernate.connection.password">myPass</property>
> >>
> >>     <property
> >> name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
> >>     <property  
> >> name="dialect">org.hibernate.dialect.MySQLDialect</property>
> >>     <property name="hibernate.connection.pool_size">5</property>
> >>     <property name="show_sql">true</property>
> >>
> >>     <property name="hibernate.c3p0.idle_test_period">1800</property>  
> >> <!--
> >> In seconds -->
> >>
> >>     <property name="hibernate.c3p0.min_size">5</property>
> >>
> >>     <property name="hibernate.c3p0.max_size">20</property>
> >>
> >>     <property name="hibernate.c3p0.timeout">2400</property>
> >>     <property name="hibernate.c3p0.max_statements">50</property>
> >>
> >> </session-factory>
> >>
> >> </hibernate-configuration>
> >>
> >> After some time, ( around 60 secs ) Hibernate complains about dropped
> >> connections, the
> >>
> >> error message looks like this :
> >>
> >> com.mysql.jdbc.CommunicationsException : Communications link failure The
> >>
> >> last packet successfully received from the server was
> >> milliseconds ago. The last packet sent successfully to the server was 0
> >>
> >> milliseconds ago.
> >>
> >> java.io.EOFException : Can not read response from server. Expected to
> >>
> >> read 4 bytes, read 0 bytes before connection was unexpectedly lost.
> >>
> >>
> >> Refeshing the page once or twice usually fixes the problem.
> >>
> >>
> >> Has anyone else encountered on this issue before, and if so, please help
> >> me. What could be possible solution to this resolution?
> >>
> >> Thanks in advance.
> >>
> >>
> >>
> >
> >
> >
> 
> 
> -- 
> Thiago H. de Paula Figueiredo
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
 		 	   		  

Re: Issue with cannot open connection

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
Guys, please don't continue this thread. This is a pure MySQL problem,  
completely unrelated to Tapestry. Thank you. ;)

On Sat, 10 Aug 2013 15:54:14 -0300, Dmitry Gusev <dm...@gmail.com>  
wrote:

> It may be that connection that is in the pool is stil open, but database
> already closed it by timeout. You need to chek timeouts in the pool so  
> that
> it be less than in the database.
>
> On Saturday, August 10, 2013, Nomen Nominus wrote:
>
>> Here is my problem. I have a very classical configuration where a webapp
>>
>> with some Hibernate code in it accesses a MySQL DB. Everything is
>>
>> installed in Tomcat 6.
>> I even acquired c3p0 connection pooling with the following  
>> configuration:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>>
>> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate
>> Configuration DTD//EN"
>>    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
>> <hibernate-configuration>
>>
>> <session-factory>
>>
>>     <!-- Settings for MySql DB -->
>>
>>     <property
>> name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
>>
>>     <property
>> name="hibernate.connection.url">jdbc:mysql://localhost:3306/myDB?autoReconnect=true</property>
>>     <property name="hibernate.connection.username">myUsername</property>
>>
>>     <property name="hibernate.connection.password">myPass</property>
>>
>>     <property
>> name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
>>     <property  
>> name="dialect">org.hibernate.dialect.MySQLDialect</property>
>>     <property name="hibernate.connection.pool_size">5</property>
>>     <property name="show_sql">true</property>
>>
>>     <property name="hibernate.c3p0.idle_test_period">1800</property>  
>> <!--
>> In seconds -->
>>
>>     <property name="hibernate.c3p0.min_size">5</property>
>>
>>     <property name="hibernate.c3p0.max_size">20</property>
>>
>>     <property name="hibernate.c3p0.timeout">2400</property>
>>     <property name="hibernate.c3p0.max_statements">50</property>
>>
>> </session-factory>
>>
>> </hibernate-configuration>
>>
>> After some time, ( around 60 secs ) Hibernate complains about dropped
>> connections, the
>>
>> error message looks like this :
>>
>> com.mysql.jdbc.CommunicationsException : Communications link failure The
>>
>> last packet successfully received from the server was
>> milliseconds ago. The last packet sent successfully to the server was 0
>>
>> milliseconds ago.
>>
>> java.io.EOFException : Can not read response from server. Expected to
>>
>> read 4 bytes, read 0 bytes before connection was unexpectedly lost.
>>
>>
>> Refeshing the page once or twice usually fixes the problem.
>>
>>
>> Has anyone else encountered on this issue before, and if so, please help
>> me. What could be possible solution to this resolution?
>>
>> Thanks in advance.
>>
>>
>>
>
>
>


-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Issue with cannot open connection

Posted by Dmitry Gusev <dm...@gmail.com>.
It may be that connection that is in the pool is stil open, but database
already closed it by timeout. You need to chek timeouts in the pool so that
it be less than in the database.

On Saturday, August 10, 2013, Nomen Nominus wrote:

> Here is my problem. I have a very classical configuration where a webapp
>
> with some Hibernate code in it accesses a MySQL DB. Everything is
>
> installed in Tomcat 6.
> I even acquired c3p0 connection pooling with the following configuration:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate
> Configuration DTD//EN"
>    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
> <hibernate-configuration>
>
> <session-factory>
>
>     <!-- Settings for MySql DB -->
>
>     <property
> name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
>
>     <property
> name="hibernate.connection.url">jdbc:mysql://localhost:3306/myDB?autoReconnect=true</property>
>     <property name="hibernate.connection.username">myUsername</property>
>
>     <property name="hibernate.connection.password">myPass</property>
>
>     <property
> name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
>     <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
>     <property name="hibernate.connection.pool_size">5</property>
>     <property name="show_sql">true</property>
>
>     <property name="hibernate.c3p0.idle_test_period">1800</property> <!--
> In seconds -->
>
>     <property name="hibernate.c3p0.min_size">5</property>
>
>     <property name="hibernate.c3p0.max_size">20</property>
>
>     <property name="hibernate.c3p0.timeout">2400</property>
>     <property name="hibernate.c3p0.max_statements">50</property>
>
> </session-factory>
>
> </hibernate-configuration>
>
> After some time, ( around 60 secs ) Hibernate complains about dropped
> connections, the
>
> error message looks like this :
>
> com.mysql.jdbc.CommunicationsException : Communications link failure The
>
> last packet successfully received from the server was
> milliseconds ago. The last packet sent successfully to the server was 0
>
> milliseconds ago.
>
> java.io.EOFException : Can not read response from server. Expected to
>
> read 4 bytes, read 0 bytes before connection was unexpectedly lost.
>
>
> Refeshing the page once or twice usually fixes the problem.
>
>
> Has anyone else encountered on this issue before, and if so, please help
> me. What could be possible solution to this resolution?
>
> Thanks in advance.
>
>
>



-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com

Re: Issue with cannot open connection

Posted by Boris Horvat <ho...@gmail.com>.
Well the version I suggested seems to be the newer and the best one to use
(I think) given that tapestry 5.3.6 is using hibernate 3.x.x.x.

I would give it a try, other then that you might want to try asking this
question in hibernate related forum as I think this is more of hibernate
problem and not tapestry

Cheers


On Sat, Aug 10, 2013 at 5:18 PM, Nomen Nominus <ge...@outlook.com>wrote:

> Hello Boris.
> I have added hibernate-c3p0 ver. 3.3.1-GA.jar to my lib folder. May that
> be the issue of the following? Should I go for 3.6.10.Final?
>
> > From: horvat.z.boris@gmail.com
> > Date: Sat, 10 Aug 2013 16:44:10 +0200
> > Subject: Re: Issue with cannot open connection
> > To: users@tapestry.apache.org
> >
> > Did you check to see if c3p0 is present in your pom? As far as I recall
> you
> > need to manually add it
> >
> >         <dependency>
> >             <groupId>org.hibernate</groupId>
> >             <artifactId>hibernate-c3p0</artifactId>
> >             <version>3.6.10.Final</version>
> >         </dependency>
> >
> > I recall having the similar problem and my solution was to add this
> (since
> > this is not included by tapestry/hibernate by default)
> >
> >
> >
> > On Sat, Aug 10, 2013 at 2:56 PM, Nomen Nominus <geribicus@outlook.com
> >wrote:
> >
> > > Here is my problem. I have a very classical configuration where a
> webapp
> > >
> > > with some Hibernate code in it accesses a MySQL DB. Everything is
> > >
> > > installed in Tomcat 6.
> > > I even acquired c3p0 connection pooling with the following
> configuration:
> > >
> > > <?xml version="1.0" encoding="UTF-8"?>
> > >
> > > <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate
> > > Configuration DTD//EN"
> > >    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
> > > <hibernate-configuration>
> > >
> > > <session-factory>
> > >
> > >     <!-- Settings for MySql DB -->
> > >
> > >     <property
> > >
> name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
> > >
> > >     <property
> > >
> name="hibernate.connection.url">jdbc:mysql://localhost:3306/myDB?autoReconnect=true</property>
> > >     <property
> name="hibernate.connection.username">myUsername</property>
> > >
> > >     <property name="hibernate.connection.password">myPass</property>
> > >
> > >     <property
> > >
> name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
> > >     <property
> name="dialect">org.hibernate.dialect.MySQLDialect</property>
> > >     <property name="hibernate.connection.pool_size">5</property>
> > >     <property name="show_sql">true</property>
> > >
> > >     <property name="hibernate.c3p0.idle_test_period">1800</property>
> <!--
> > > In seconds -->
> > >
> > >     <property name="hibernate.c3p0.min_size">5</property>
> > >
> > >     <property name="hibernate.c3p0.max_size">20</property>
> > >
> > >     <property name="hibernate.c3p0.timeout">2400</property>
> > >     <property name="hibernate.c3p0.max_statements">50</property>
> > >
> > > </session-factory>
> > >
> > > </hibernate-configuration>
> > >
> > > After some time, ( around 60 secs ) Hibernate complains about dropped
> > > connections, the
> > >
> > > error message looks like this :
> > >
> > > com.mysql.jdbc.CommunicationsException : Communications link failure
> The
> > >
> > > last packet successfully received from the server was
> > > milliseconds ago. The last packet sent successfully to the server was 0
> > >
> > > milliseconds ago.
> > >
> > > java.io.EOFException : Can not read response from server. Expected to
> > >
> > > read 4 bytes, read 0 bytes before connection was unexpectedly lost.
> > >
> > >
> > > Refeshing the page once or twice usually fixes the problem.
> > >
> > >
> > > Has anyone else encountered on this issue before, and if so, please
> help
> > > me. What could be possible solution to this resolution?
> > >
> > > Thanks in advance.
> > >
> > >
> > >
> >
> >
> >
> >
> > --
> > Sincerely
> > *Boris Horvat*
>




-- 
Sincerely
*Boris Horvat*

RE: Issue with cannot open connection

Posted by Nomen Nominus <ge...@outlook.com>.
Hello Boris.
I have added hibernate-c3p0 ver. 3.3.1-GA.jar to my lib folder. May that be the issue of the following? Should I go for 3.6.10.Final?

> From: horvat.z.boris@gmail.com
> Date: Sat, 10 Aug 2013 16:44:10 +0200
> Subject: Re: Issue with cannot open connection
> To: users@tapestry.apache.org
> 
> Did you check to see if c3p0 is present in your pom? As far as I recall you
> need to manually add it
> 
>         <dependency>
>             <groupId>org.hibernate</groupId>
>             <artifactId>hibernate-c3p0</artifactId>
>             <version>3.6.10.Final</version>
>         </dependency>
> 
> I recall having the similar problem and my solution was to add this (since
> this is not included by tapestry/hibernate by default)
> 
> 
> 
> On Sat, Aug 10, 2013 at 2:56 PM, Nomen Nominus <ge...@outlook.com>wrote:
> 
> > Here is my problem. I have a very classical configuration where a webapp
> >
> > with some Hibernate code in it accesses a MySQL DB. Everything is
> >
> > installed in Tomcat 6.
> > I even acquired c3p0 connection pooling with the following configuration:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> >
> > <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate
> > Configuration DTD//EN"
> >    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
> > <hibernate-configuration>
> >
> > <session-factory>
> >
> >     <!-- Settings for MySql DB -->
> >
> >     <property
> > name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
> >
> >     <property
> > name="hibernate.connection.url">jdbc:mysql://localhost:3306/myDB?autoReconnect=true</property>
> >     <property name="hibernate.connection.username">myUsername</property>
> >
> >     <property name="hibernate.connection.password">myPass</property>
> >
> >     <property
> > name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
> >     <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
> >     <property name="hibernate.connection.pool_size">5</property>
> >     <property name="show_sql">true</property>
> >
> >     <property name="hibernate.c3p0.idle_test_period">1800</property> <!--
> > In seconds -->
> >
> >     <property name="hibernate.c3p0.min_size">5</property>
> >
> >     <property name="hibernate.c3p0.max_size">20</property>
> >
> >     <property name="hibernate.c3p0.timeout">2400</property>
> >     <property name="hibernate.c3p0.max_statements">50</property>
> >
> > </session-factory>
> >
> > </hibernate-configuration>
> >
> > After some time, ( around 60 secs ) Hibernate complains about dropped
> > connections, the
> >
> > error message looks like this :
> >
> > com.mysql.jdbc.CommunicationsException : Communications link failure The
> >
> > last packet successfully received from the server was
> > milliseconds ago. The last packet sent successfully to the server was 0
> >
> > milliseconds ago.
> >
> > java.io.EOFException : Can not read response from server. Expected to
> >
> > read 4 bytes, read 0 bytes before connection was unexpectedly lost.
> >
> >
> > Refeshing the page once or twice usually fixes the problem.
> >
> >
> > Has anyone else encountered on this issue before, and if so, please help
> > me. What could be possible solution to this resolution?
> >
> > Thanks in advance.
> >
> >
> >
> 
> 
> 
> 
> -- 
> Sincerely
> *Boris Horvat*
 		 	   		  

Re: Issue with cannot open connection

Posted by Boris Horvat <ho...@gmail.com>.
Did you check to see if c3p0 is present in your pom? As far as I recall you
need to manually add it

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-c3p0</artifactId>
            <version>3.6.10.Final</version>
        </dependency>

I recall having the similar problem and my solution was to add this (since
this is not included by tapestry/hibernate by default)



On Sat, Aug 10, 2013 at 2:56 PM, Nomen Nominus <ge...@outlook.com>wrote:

> Here is my problem. I have a very classical configuration where a webapp
>
> with some Hibernate code in it accesses a MySQL DB. Everything is
>
> installed in Tomcat 6.
> I even acquired c3p0 connection pooling with the following configuration:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate
> Configuration DTD//EN"
>    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
> <hibernate-configuration>
>
> <session-factory>
>
>     <!-- Settings for MySql DB -->
>
>     <property
> name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
>
>     <property
> name="hibernate.connection.url">jdbc:mysql://localhost:3306/myDB?autoReconnect=true</property>
>     <property name="hibernate.connection.username">myUsername</property>
>
>     <property name="hibernate.connection.password">myPass</property>
>
>     <property
> name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
>     <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
>     <property name="hibernate.connection.pool_size">5</property>
>     <property name="show_sql">true</property>
>
>     <property name="hibernate.c3p0.idle_test_period">1800</property> <!--
> In seconds -->
>
>     <property name="hibernate.c3p0.min_size">5</property>
>
>     <property name="hibernate.c3p0.max_size">20</property>
>
>     <property name="hibernate.c3p0.timeout">2400</property>
>     <property name="hibernate.c3p0.max_statements">50</property>
>
> </session-factory>
>
> </hibernate-configuration>
>
> After some time, ( around 60 secs ) Hibernate complains about dropped
> connections, the
>
> error message looks like this :
>
> com.mysql.jdbc.CommunicationsException : Communications link failure The
>
> last packet successfully received from the server was
> milliseconds ago. The last packet sent successfully to the server was 0
>
> milliseconds ago.
>
> java.io.EOFException : Can not read response from server. Expected to
>
> read 4 bytes, read 0 bytes before connection was unexpectedly lost.
>
>
> Refeshing the page once or twice usually fixes the problem.
>
>
> Has anyone else encountered on this issue before, and if so, please help
> me. What could be possible solution to this resolution?
>
> Thanks in advance.
>
>
>




-- 
Sincerely
*Boris Horvat*