Tuesday 15 June 2010

sql server - sleeping/awaiting command processes due to misconfiguring tomcat+hibernate+database -


I am working on a legacy code and I have been asked to find out why so many Sleeping / Waiting order In procedures sql server db . Most of them do not have program_name = 'jtds' in all, so take a lot of CPU + physical_off and 10+ days old.

And I was watching it more and I was going to find out that it would have to do something with database pooling.

It appears that we have two places where we are using DB pooling: reference reference.xml • applicationContext.xml reads in the Web.xml, on the initial load of the application which in turn Takes context.xml and makes it a container holdable DB connection.

The Web XML also takes applicationContext.xml for spring reference information.

When SessionFactory needs to configure the hibernate setting, which is visible to Hibernate Properties.

context.xml

  & lt; Resource auth = "container" description = "DPS database" driverClass = "net Sourceforge.jtds.jdbc.Driver" name = "jdbc / vda" user = "****" password = "*****" factory = "Org.apache.naming.factory.BeanFactory" type = "com Mchange.v2.c3p0.ComboPooledDataSource" jdbcUrl = "jdbc: jtds: sqlserver: // localhost / dbname; user = sa; password = ****; tds = 8.0 "/>  

web.xml

  & lt; Resource-Ref & gt; & Lt; Details & gt; The pooled database resource & lt; / Description & gt; & Lt; Race-referee-name & gt; JDBC / VDA & lt; / Race-referee-name & gt; & Lt; Race Type & gt; Ja`vax.sql.DataSource & lt; / Race Type & gt; & Lt; Race writing & gt; Container & lt; / Writing the race & gt; & Lt; Race division-scope & gt; Shareable & lt; / RR sharing scope & gt; & Lt; / Resources Ref & gt; & Lt; Context param & gt; & Lt; Ultimate Name & gt; ContextConfigLocation & lt; / Lastname & gt; & Lt; Ultimate Price & gt; /WEB-INF/applicationContext.xml< / Super-valued & gt; & Lt; / Reference param & gt;  

applicationContext.xml

  & lt ;! - Using Data Source C3P0 Database Connection Pooling - & gt; & Lt; Bean id = "data source" category = "org.springframework.jndi.JndiObjectFactoryBean" & gt; & Lt; Property Name = "jndiName" & gt; & Lt; Price & gt; Java: computer application / env / jdbc / vda & lt; / Pricing & gt; & Lt; / Property & gt; & Lt; / Bean & gt; & Lt ;! - Hibernate properties used in session factory - & gt; & Lt; Bean id = "hibernate properties" category = "org.springframework.beans.factory.config.PropertiesFactoryBean" & gt; & Lt; Property Name = "Properties" & gt; & Lt; Theater Content & gt; & Lt; Prop key = "hibernate.hbm2ddl.auto" & gt; Update & lt; / Prop & gt; & Lt; Prop key = "hibernate.dialect" & gt; Org.hibernate.dialect.SQLServerDialect & lt; / Prop & gt; & Lt; Prop key = "hibernate.show_sql" & gt; False & lt; / Prop & gt; & Lt; Prop key = "hibernate.c3p0.min_size" & gt; 4 & lt; / Prop & gt; & Lt; Prop key = "hibernate.c3p0.max_size" & gt; 10 & lt; / Prop & gt; & Lt; Prop key = "hibernate.c3p0.timeout" & gt; 300 & lt; / Prop & gt; & Lt; Prop key = "hibernate.c3p0.max_statements" & gt; 20 & lt; / Prop & gt; & Lt; Prop key = "hibernate.c3p0.testConnectionOnCheckout" & gt; Wrong & lt; / Prop & gt; & Lt; Prop key = "hibernate.cache.use_second_level_cache" & gt; Wrong & lt; / Prop & gt; & Lt; / Theater & gt; & Lt; / Property & gt; & Lt; / Bean & gt; & Lt ;! - Hibernation session factory - & gt; & Lt; Bean id = "sessionFactory" class = "org.springframework.orm.hibernate3.LocalSessionFactoryBean" & gt; & Lt; Property Name = "Data Source" Riff = "Data Sources" / & gt; & Lt; Property Name = "Hibernate Properties" referee = "Hibernate Properties" /> & Lt; Property Name = "Mapping Resources" & gt; & Lt; List & gt; & Lt; Price & gt; Model / businessobject / login / user.hbm.xml & lt; / Pricing & gt; & Lt; / List & gt; & Lt; / Property & gt; & Lt; / Bean & gt;  

I added the context.xml file to maxActive = "30" maxIdle = "10" maxWait = "3000" .

I also said:

  & lt; Prop key = "hibernate.c3p0.maxIdleTime" & gt; 1800 & lt; / Prop & gt; & Lt; Prop key = "hibernate.c3p0.idle_test_periods" & gt; 30 & lt; / Prop & gt;  

to applicationContext.xml

It seems that there are 2 places where we are setting c3p0 value, if that is what we need both of them?

Is this my problem? Can anyone see the wrong?


No comments:

Post a Comment