こんにちは、ログに次のメッセージが記録されています:
2013-05-14 01:32:47,079}ABSOLUTE{ INFO org.hibernate.cfg.Configuration}1{:2074 - HHH000041: Configured SessionFactory: null
接続が多すぎるためにアプリが最終的に失敗するという問題があります。これらが関連しているような気がします。私はこれを読みました。このサイトで、しかし、私は本当に解決策を見つけることができません. ここに、SessionFactoryUtil と hibernate.cfg.xml のコードを示します。任意のポインタをいただければ幸いです。
public class SessionFactoryUtil {
private static SessionFactory sessionFactory;
private static ServiceRegistry serviceRegistry;
private static SessionFactory configureSessionFactory()
throws HibernateException {
Configuration configuration = new Configuration();
configuration.configure();
serviceRegistry = new ServiceRegistryBuilder()
.applySettings(configuration.getProperties())
.buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
return sessionFactory;
}
public static SessionFactory getInstance() {
return configureSessionFactory();
//return sessionFactory;
}
public Session getCurrentSession() {
return sessionFactory.getCurrentSession();
}
public static void close() {
if (sessionFactory != null) {
sessionFactory.close();
sessionFactory = null;
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">xxxxxxxx</property>
<property name="hibernate.connection.url">jdbc:mysql://xxxxx.cvo0kkopzfhs.us-west-1.rds.amazonaws.com/homemoviezoo</property>
<property name="hibernate.connection.username">xxxxx</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="log4jdbc.drivers">jdbc:log4jdbc:mysql://xxxxcvo0kkopzfhs.us-west-1.rds.amazonaws.com/homemoviezoo</property>
<!-- configuration pool via c3p0-->
<property name="c3p0.acquire_increment">1</property>
<property name="c3p0.idle_test_period">800</property> <!-- seconds -->
<property name="c3p0.max_size">20</property>
<property name="c3p0.max_statements">20</property>
<property name="c3p0.min_size">5</property>
<property name="c3p0.timeout">1800</property> <!-- seconds -->
<property name="c3p0.maxConnectionAge">1200</property>
<property name="conneciton.provider_class">
org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="current_session_context_class">thread</property>
<property name="hibernate.show_sql">true</property>
<!-- <property name="hbm2ddl.auto">update</property>-->
<mapping class="com.local.shared.School"/>
<mapping class="com.local.shared.SchoolVideo"/>
<mapping class="com.local.shared.Category"/>
<mapping class="com.local.shared.Administrator"/>
</session-factory>
</hibernate-configuration>