-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Problems when DB is down
PostPosted: Mon Jun 09, 2008 7:22 pm 
Newbie

Joined: Mon Jun 09, 2008 6:55 pm
Posts: 3
Location: Israel, Haifa
Hi,

I've encountered a problem which I can't seem to resolve or find the source of it...
My version of hibernate: 3.2. I'm using the C3P0 connection pool (hbm config file attached).
When I create a session factory with my hibernate.cfg.xml config file and the DB (mysql Ver 14.12 Distrib 5.0.45, for Win32) is up and running, all works fine.
But, when the DB is down (service is stopped and no connections from the console can be made), a loop of repeated exceptions is printed to the console (never stops):
Code:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Last packet sent to the server was 0 ms ago.
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
   at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
... (more & repeated)


I've noticed another thing which I cannot explain:
When I remove the C3P0 configurations from the file, I do not get the loop of repeated exception as above. A session factory and a session are created (session.isConnected() returns true!), no exceptions are thrown and no warnings are printed to the console.

My questions:
1) How can I resolve the endless exceptions loop? (first problem)
2) When I'm not using the C3P0 connections pool, why is a session created with no errors?

I believe that I'm missing something here, but can't tell what.


This is my hbm file:

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="hibernate.connection.url">
jdbc:mysql://localhost/nswdb
</property>
<property name="hibernate.connection.username">nswuser</property>
<property name="hibernate.connection.password">1234</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

<property name="hibernate.hbm2ddl.auto">update</property>



<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">1800</property>
<property name="hibernate.c3p0.max_statements">50</property>



<!-- Mapping files -->
<mapping resource="NSWUser.hbm.xml"/>
<mapping resource="NSWPerson.hbm.xml"/>
<mapping resource="NSWGroup.hbm.xml"/>
<mapping resource="NSWBackToSmokingReason.hbm.xml"/>
<mapping resource="NSWOrganization.hbm.xml"/>
<mapping resource="NSWStopSmokingReason.hbm.xml"/>
<mapping resource="NSWMedication.hbm.xml"/>
<mapping resource="NSWMethod.hbm.xml"/>
<mapping resource="NSWSession.hbm.xml"/>
<mapping resource="NSWPatientInSession.hbm.xml" />

</session-factory>
</hibernate-configuration>


This is how I create a session:

Code:
SessionFactory factory = HibernateUtil.getSessionFactory(hbmFile);
            
session = factory.openSession();


Help & explanations appreciated!

_________________
Thanks,

Omri


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 11, 2008 9:42 am 
Newbie

Joined: Mon Jun 09, 2008 6:55 pm
Posts: 3
Location: Israel, Haifa
Hi,

Anyone?

_________________
Thanks,

Omri


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.