Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version='1.0' encoding='UTF-8'?>
- <!DOCTYPE hibernate-configuration PUBLIC
- "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
- "http://hibernate.org/dtd/hibernate-configuration-3.0.dtd">
- <hibernate-configuration>
- <session-factory>
- <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
- <property name="connection.driver_class">org.postgresql.Driver</property>
- <property name="connection.url">jdbc:postgresql://localhost:5432/netstat</property>
- <property name="connection.username">netstat</property>
- <property name="connection.password">netstat</property>
- <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
- <!-- configuration pool via c3p0 -->
- <property name="c3p0.min_size">5</property>
- <property name="c3p0.max_size">100</property>
- <property name="c3p0.max_statements">200</property>
- <property name="c3p0.timeout">600</property> <!-- seconds -->
- <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
- <property name="current_session_context_class">thread</property>
- <property name="hibernate.show_sql">false</property>
- <property name="hibernate.hbm2ddl.auto">update</property>
- <!-- Mapping classes -->
- <mapping class="ru.gooamoko.model.Group" />
- <mapping class="ru.gooamoko.model.Host" />
- <mapping class="ru.gooamoko.model.Traffic" />
- <mapping class="ru.gooamoko.model.DailyTraffic" />
- </session-factory>
- </hibernate-configuration>
- package ru.gooamoko.dao;
- import org.hibernate.SessionFactory;
- import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
- import org.hibernate.cfg.Configuration;
- import org.hibernate.service.ServiceRegistry;
- public class HibernateProvider {
- private static SessionFactory factory;
- private static ServiceRegistry registry;
- public static SessionFactory getSessionFactory() {
- Configuration configuration = new Configuration();
- configuration.configure();
- registry = new StandardServiceRegistryBuilder().applySettings(
- configuration.getProperties()).build();
- factory = configuration.buildSessionFactory(registry);
- return factory;
- }
- }
- package ru.gooamoko.dao;
- import org.hibernate.Session;
- import org.hibernate.SessionFactory;
- public class GenericDao {
- private SessionFactory factory;
- protected Session session;
- protected void begin() {
- session = factory.getCurrentSession();
- session.beginTransaction();
- }
- protected void commit() {
- if (session.isOpen()) {
- session.getTransaction().commit();
- }
- }
- protected void rollback() {
- if (session.isOpen()) {
- session.getTransaction().rollback();
- }
- }
- public GenericDao() {
- this.factory = HibernateProvider.getSessionFactory();
- }
- }
- 27-Aug-2014 15:06:24.559 WARNING [C3P0PooledConnectionPoolManager[identityToken->1hge12w9467h4hm1tfa5tj|3b40a97d]-HelperThread-#2] com.mchange.v2.resourcepool.BasicResourcePool.forceKillAcquires Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@4df5a3a4 is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
- 27-Aug-2014 15:06:24.563 WARNING [C3P0PooledConnectionPoolManager[identityToken->1hge12w9467h4hm1tfa5tj|3b40a97d]-HelperThread-#2] com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@628977a2 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
- org.postgresql.util.PSQLException: ?????: ?????????? ????? ??????????? ??????????????? ??? ??????????? ????????????????? (?? ??? ??????????)
- at org.postgresql.core.v3.ConnectionFactoryImpl.readStartupMessages(ConnectionFactoryImpl.java:572)
- at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:177)
- at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64)
- at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:136)
- at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:29)
- at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:21)
- at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:31)
- at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
- at org.postgresql.Driver.makeConnection(Driver.java:393)
- at org.postgresql.Driver.connect(Driver.java:267)
- at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146)
- at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)
- at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)
- at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
- at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
- at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
- at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
- at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)
- at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)
- package ru.gooamoko.dao;
- import org.hibernate.HibernateException;
- import org.hibernate.SessionFactory;
- import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
- import org.hibernate.cfg.Configuration;
- import org.hibernate.service.ServiceRegistry;
- public class HibernateProvider {
- private static final SessionFactory factory = buildFactory();
- public static SessionFactory getSessionFactory() {
- return factory;
- }
- private static SessionFactory buildFactory() {
- try {
- Configuration configuration = new Configuration();
- configuration.configure();
- ServiceRegistry registry = new StandardServiceRegistryBuilder().applySettings(
- configuration.getProperties()).build();
- return configuration.buildSessionFactory(registry);
- } catch (HibernateException ex) {
- // Make sure you log the exception, as it might be swallowed
- System.err.println("Initial SessionFactory creation failed." + ex);
- throw new ExceptionInInitializerError(ex);
- }
- }
- }
- SELECT COUNT(*) FROm pg_stat_activity;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement