I do a project on heroku (free account). I use Sping + Hibernate + MySQL . As soon as I go to the site, everything works fine, but if I don’t turn to the database for a few seconds, they fall and the pages that turn to the database give an error. What could be the problem? When I run the application locally from an idea and connect to the same database, everything works fine.
Maybe my persistance.xml is not configured correctly? Tell me, please, how can I configure autoreconnect or increase the timeout, or what else can I do there ???
The full error message can be seen by clicking on the "Search" button (only when entering the site you need to wait less than a minute: https://kiev-lease.herokuapp.com
My persistance.xml (commented out code is what I tried myself)
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0"> <persistence-unit name="FlatsJPA" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> <properties> <property name="hibernate.show_sql" value="true" /> <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" /> <!--<property name="javax.persistence.jdbc.url" value="jdbc:mysql://eu-cdbr-west-01.cleardb.com:3306/heroku_a2736c1ec063973?reconnect=true"/>--> <property name="javax.persistence.jdbc.url" value="jdbc:mysql://eu-cdbr-west-01.cleardb.com:3306/heroku_a2736c1ec063973?autoReconnect=true"/> <property name="javax.persistence.jdbc.user" value="b73b29b287469f" /> <property name="javax.persistence.jdbc.password" value="4e7a84e0" /> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> <property name="hibernate.hbm2ddl.auto" value="update"/> <!--<property name="hibernate.c3p0.min_size" value="10"/>--> <!--<property name="hibernate.c3p0.max_size" value="280"/>--> <!--<property name="hibernate.c3p0.timeout" value="100"/>--> <!--<property name="hibernate.c3p0.max_statements" value="0"/>--> <!--<property name="hibernate.c3p0.idle_test_period" value="300"/>--> <!--<property name="hibernate.c3p0.autoCommitOnClose" value="false"/>--> <!--<property name="hibernate.c3p0.preferredTestQuery" value="SELECT 1"/>--> <!--<property name="hibernate.c3p0.unreturnedConnectionTimeout"--> <!--value="60"/>--> <!--<property name="hibernate.c3p0.min_size" value="5"/>--> <!--<property name="hibernate.c3p0.max_size" value="20"/>--> <!--<property name="hibernate.c3p0.timeout" value="1800"/>--> <!--<property name="hibernate.c3p0.max_statements" value="50"/>--> <!--<property name="hibernate.c3p0.idle_test_period" value="1800"/>--> <!--<property name="c3p0.idleConnectionTestPeriod" value="1810"/>--> </properties> </persistence-unit>