我使用的是struts2+hibernate4.2+proxool配置
当我修改某些文件导致tomcat需要重载的时候报以下错误;
2013-10-30 9:47:05 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/HibernateProxool] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2013-10-30 9:47:05 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/HibernateProxool] registered the JDBC driver [org.logicalcobwebs.proxool.ProxoolDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2013-10-30 9:47:05 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/HibernateProxool] appears to have started a thread named [HouseKeeper] but has failed to stop it. This is very likely to create a memory leak.
2013-10-30 9:47:05 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/HibernateProxool] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak.
proxool.xml的配置是:
<?xml version="1.0" encoding="UTF-8"?>
<!--
the proxool configuration can be embedded within your own
application's. Anything outside the "proxool" tag is ignored.
-->
<something-else-entirely>
<proxool>
<alias>dbname</alias>
<driver-url>jdbc:mysql://localhost:3306/bbs</driver-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver-properties>
<property name="user" value="root" />
<property name="password" value="root" />
</driver-properties>
<maximum-connection-count>50</maximum-connection-count>
<minimum-connection-count>8</minimum-connection-count>
<house-keeping-sleep-time>90000</house-keeping-sleep-time>
<simultaneous-build-throttle>8</simultaneous-build-throttle>
<!--
<maximum-new-connections>8</maximum-new-connections>
-->
<prototype-count>5</prototype-count>
<test-before-use>true</test-before-use>
<house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql>
</proxool>
</something-else-entirely> hibernate.properties文件:
hibernate.dialect org.hibernate.dialect.MySQLDialect
hibernate.proxool.pool_alias dbname
hibernate.proxool.xml proxool.xml
hibernate.connection.provider_class org.hibernate.connection.ProxoolConnectionProviderhibernate.jdbc.fetch_size 50
hibernate.jdbc.batch_size 25
use_outer_join false
use_reflection_optimizer false
hibernate.cglib.use_reflection_optimizer false
jdbc.use_scrollable_resultset trueconnection.autoReconnect true
connection.autoReconnectForPools true
connection.is-connection-validation-required truehibernate.hbm2ddl.auto update
hibernate.format_sql true
hibernate.show_sql true
工厂类:
package Util;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistryBuilder;public class HibernateUtil {
private static final HibernateUtil instance = new HibernateUtil();
private SessionFactory sf;
private HibernateUtil(){
//读取配置文件并启动框架
Configuration cfg = new Configuration();
cfg.configure();
sf = cfg.buildSessionFactory(new ServiceRegistryBuilder()
.loadProperties("hibernate.properties").buildServiceRegistry());
} public static HibernateUtil getInstance() {
return instance;
}
public Session getSession(){
return sf.openSession();
}
}
实用类:
package Actions;
import java.util.List;import org.hibernate.Session;import Util.HibernateUtil;
import VO.User;import com.opensymphony.xwork2.ActionSupport;public class proxoolAction extends ActionSupport {
@Override
public String execute() throws Exception {
Session session = HibernateUtil.getInstance().getSession();
// HibernateUtil.getInstance();
session.beginTransaction();
List<User> users = session.createQuery("FROM User").list();
for(User u : users){
System.out.println(u);
}
session.getTransaction().commit();
session.close();
return SUCCESS;
}
}
另外就是有一个警告的提示:
2013-10-30 09:51:04,519 WARN [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] - HHH000208: org.hibernate.connection.ProxoolConnectionProvider has been deprecated in favor of org.hibernate.service.jdbc.connections.internal.ProxoolConnectionProvider; that provider will be used instead.求大神指导!!!!
当我修改某些文件导致tomcat需要重载的时候报以下错误;
2013-10-30 9:47:05 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/HibernateProxool] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2013-10-30 9:47:05 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/HibernateProxool] registered the JDBC driver [org.logicalcobwebs.proxool.ProxoolDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2013-10-30 9:47:05 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/HibernateProxool] appears to have started a thread named [HouseKeeper] but has failed to stop it. This is very likely to create a memory leak.
2013-10-30 9:47:05 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/HibernateProxool] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak.
proxool.xml的配置是:
<?xml version="1.0" encoding="UTF-8"?>
<!--
the proxool configuration can be embedded within your own
application's. Anything outside the "proxool" tag is ignored.
-->
<something-else-entirely>
<proxool>
<alias>dbname</alias>
<driver-url>jdbc:mysql://localhost:3306/bbs</driver-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver-properties>
<property name="user" value="root" />
<property name="password" value="root" />
</driver-properties>
<maximum-connection-count>50</maximum-connection-count>
<minimum-connection-count>8</minimum-connection-count>
<house-keeping-sleep-time>90000</house-keeping-sleep-time>
<simultaneous-build-throttle>8</simultaneous-build-throttle>
<!--
<maximum-new-connections>8</maximum-new-connections>
-->
<prototype-count>5</prototype-count>
<test-before-use>true</test-before-use>
<house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql>
</proxool>
</something-else-entirely> hibernate.properties文件:
hibernate.dialect org.hibernate.dialect.MySQLDialect
hibernate.proxool.pool_alias dbname
hibernate.proxool.xml proxool.xml
hibernate.connection.provider_class org.hibernate.connection.ProxoolConnectionProviderhibernate.jdbc.fetch_size 50
hibernate.jdbc.batch_size 25
use_outer_join false
use_reflection_optimizer false
hibernate.cglib.use_reflection_optimizer false
jdbc.use_scrollable_resultset trueconnection.autoReconnect true
connection.autoReconnectForPools true
connection.is-connection-validation-required truehibernate.hbm2ddl.auto update
hibernate.format_sql true
hibernate.show_sql true
工厂类:
package Util;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistryBuilder;public class HibernateUtil {
private static final HibernateUtil instance = new HibernateUtil();
private SessionFactory sf;
private HibernateUtil(){
//读取配置文件并启动框架
Configuration cfg = new Configuration();
cfg.configure();
sf = cfg.buildSessionFactory(new ServiceRegistryBuilder()
.loadProperties("hibernate.properties").buildServiceRegistry());
} public static HibernateUtil getInstance() {
return instance;
}
public Session getSession(){
return sf.openSession();
}
}
实用类:
package Actions;
import java.util.List;import org.hibernate.Session;import Util.HibernateUtil;
import VO.User;import com.opensymphony.xwork2.ActionSupport;public class proxoolAction extends ActionSupport {
@Override
public String execute() throws Exception {
Session session = HibernateUtil.getInstance().getSession();
// HibernateUtil.getInstance();
session.beginTransaction();
List<User> users = session.createQuery("FROM User").list();
for(User u : users){
System.out.println(u);
}
session.getTransaction().commit();
session.close();
return SUCCESS;
}
}
另外就是有一个警告的提示:
2013-10-30 09:51:04,519 WARN [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] - HHH000208: org.hibernate.connection.ProxoolConnectionProvider has been deprecated in favor of org.hibernate.service.jdbc.connections.internal.ProxoolConnectionProvider; that provider will be used instead.求大神指导!!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货