Wednesday, 15 June 2011

java - c3p0 do not timeout when are impossible to reach the host -


The first time when my program is open, try to connect to the database, if c3p0 closes it And freeze any error message.

The strange thing is that I got java.net.UnknownHostException with MySQL , but with SqlServer something Not even this, it keeps trying forever.

I want to catch error and do something. I tried to set this property but there was no luck.

  & lt; Property Name = "hibernate.c3p0.timeout" value = "60" /> & Lt; Property Name = "hibernate.c3p0.unreturnedConnectionTimeout" value = "60" />  

My persistence.xml

  & lt ;? Xml version = "1.0" encoding = "UTF-8" & gt; & Lt; Persistence version = "2.1" xmlns = "http://xmlns.jcp.org/xml/ns/produstence" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" XSI: Schema Locations = "Http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> & Lt; Persistence Unit Name = "Default" Transaction Type = "RESOURCE_LOCAL" & gt; & Lt; Provider & gt; Org.hibernate.jpa.HibernatePersistenceProvider & lt; / Provider & gt; & Lt; Classes & gt; Com.lala.Something & lt; / Square & gt; & Lt; Share-cache-mode & gt; Nobody & lt; / Share-cache-mode & gt; & Lt; Properties & gt; & Lt ;! - Connection - & gt; & Lt; Property Name = "javax.persistence.jdbc.url" value = "jdbc: sqlserver: // localhost \\\\ SQLEXPRESS: 1433; database name = string" /> & Lt; Property Name = "javax.persistence.jdbc.driver" value = "com.microsoft.sqlserver.jdbc.SQLServerDriver" /> & Lt; Property Name = "javax.persistence.jdbc.user" value = "teste" /> & Lt; Property Name = "javax.persistence.jdbc.password" value = "teste" /> & Lt ;! - Hibernate - & gt; & Lt; Property Name = "hibernate.format_sql" value = "false" /> & Lt; Property Name = "hibernate.show_sql" value = "false" /> & Lt; Property Name = "hibernate.use_sql_comments" value = "false" /> & Lt ;! - c3p0 - & gt; & Lt; Property Name = "hibernate.connection.provider_class" value = "org.hibernate.connection.C3P0ConnectionProvider" /> & Lt; Property Name = "hibernate.c3p0.min_size" value = "1" /> & Lt; / Properties & gt; & Lt; / Persistence unit & gt; & Lt; / Persistence> If c3p0 tries to get a connection from a database, and attempts to "hang" those acquisition attempts, then  

notification draconock and will be reconstructed automatically.

Two qualities that you have attempted to set up, neither two of them are relevant to the trouble. If you want to work around these braces, then c3p0 will look for the configuration properties.


No comments:

Post a Comment