Reputation: 16
I'm new to JPA & Hibernate, I'm performing reset password action. In that case, the entity object (User) is getting updated after that I'm trying to log-in but unfortunately, the server is hung and I was getting the below exception.
javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Unable to release JDBC Connection
Below is our persistence file configuration
<properties>
<!-- Configuring JDBC properties -->
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://127.0.0.1:3306/dbname?autoReconnect=true&useUnicode=true" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver" />
<property name="javax.persistence.jdbc.user" value="username" />
<property name="javax.persistence.jdbc.password" value="password" />
<property name="hibernate.jdbc.batch_size" value="80000" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.use_sql_comments" value="false" />
<property name="hibernate.hbm2ddl.auto" value="none" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.connection.charSet" value="UTF-8" />
<property name="hibernate.max_fetch_depth" value="2" />
<!-- Configuring Connection Pool -->
<property name="hibernate.c3p0.min_size" value="10" />
<property name="hibernate.c3p0.max_size" value="250" />
<property name="hibernate.c3p0.acquire_increment" value="10"/>
<property name="hibernate.c3p0.timeout" value="500" />
<property name="hibernate.c3p0.max_statements" value="50" />
<property name="hibernate.c3p0.idle_test_period" value="2000" />
<!-- Newly added -->
<property name="hibernate.c3p0.maxConnectionAge" value="300"/>
<property name="hibernate.c3p0.maxIdleTimeExcessConnections" value="300"/>
<property name="hibernate.c3p0.testConnectionOnCheckin" value="true"/>
<property name="hibernate.c3p0.preferredTestQuery" value="select 1"/>
<property name="hibernate.c3p0.validate" value="false"/>
<property name="hibernate.c3p0.testConnectionOnCheckout" value="false" />
</properties>
Can anyone help me what I made mistake? anything I missed in the configuration file?
Upvotes: 0
Views: 8956
Reputation: 161
This is my set up and works perfect with hibernate 5.2.4 and spring mvc 4.3.4 and Maven 3.3.9
<!-- Set Up data base DataSource and the connection pool -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/mySchemaName?useSSL=false" />
<property name="user" value="root" />
<property name="password" value="**********" />
<!-- the connection pool properties for C3P0 -->
<property name="minPoolSize" value="5" />
<property name="maxPoolSize" value="20" />
<property name="maxIdleTime" value="30000" />
</bean>
<!-- Setu session factory for Hibernate -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.package.whatever" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<!-- Setup Hibernate transaction manager -->
<bean id="myTransactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
Tip: If you are using glassfish server 4.1.1 you have to find glasfish/domains/domain1/modules and replace jboss-logger with the newest jboss-logger 3.3.0
Upvotes: 1