|
Re: Hibernate timeout on connection [message #1004243 is a reply to message #1004193] |
Tue, 22 January 2013 21:25 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Rafael,
Hmm, I would need to do a google search to reply on this question, I guess it is possible to set a connection timeout,
maybe you have autoReconnect set somehow (this is possible with mysql it seems).
Let me know if you find any specific solutions when searching the net. It would be great if you can post any solutions here.
gr. Martin
On 01/22/2013 08:16 PM, Rafael Fogel wrote:
> I have a small app that connects on multiple hosts, but sometimes those hosts are down or I can't access by some reasons.
>
> I am connecting like this:
>
> serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
>
> sessionFactory = configuration.buildSessionFactory(serviceRegistry);
>
> Hibernate keeps trying to connect forever on unreachable host. Is there a way to set a timeout on hibernate connection?
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
|
|
Re: Hibernate timeout on connection [message #1005753 is a reply to message #1005729] |
Mon, 28 January 2013 14:53 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Have you tried without the autoReconnect option?
In your first post, when say tries to reconnect forever. It means that hibernate tries many times to create a
connection? Or that one connection hangs indefinitely?
gr. Martin
On 01/28/2013 01:47 PM, Rafael Fogel wrote:
> Yes, I am using c3p0, connectinng on MySQl
>
> Here's my hibernate configuration:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE hibernate-configuration PUBLIC
> "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
> "http://hibernate.sourceforge.net/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">****</property>
> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/flexadmin</property>
> <property name="hibernate.connection.username">***</property>
> <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
> <property name="hibernate.show_sql">true</property>
> <property name="hibernate.auto">true</property>
> <property name="hibernate.connection.autoReconnect">true</property> <property
> name="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property>
> <property name="hibernate.c3p0.acquire_increment">1</property>
> <property name="hibernate.c3p0.validate">true</property>
> <property name="hibernate.c3p0.min_size">5</property>
> <property name="hibernate.c3p0.max_size">100</property>
> <property name="hibernate.c3p0.timeout">1800</property>
> <property name="hibernate.c3p0.max_statements">50</property>
> <property name="hibernate.c3p0.preferredTestQuery">SELECT 1;</property>
> <property name="hibernate.c3p0.testConnectionOnCheckout">true</property>
> <property name="hibernate.c3p0.idle_test_period">100</property>
> </session-factory>
> </hibernate-configuration>
>
> As far as I know, c3p0 timeout refers to the connection's lifetime, not the attempt to connect.
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02810 seconds