读书人

Hibernate+proxool链接数据失败是什么

发布时间: 2011-12-04 22:58:58 作者: rapoo

Hibernate+proxool链接数据失败是什么原因?
配置好了之后访问是TOMCAT报如下错误:
Proxool Provider unable to load JAXP configurat or file: proxool.xml
以下是所用到的代码,请大家帮我看看问题出在那里了?谢谢!


[hibernate.cfg.xml]代码如下:

<?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.proxool.pool_alias "> dbpool </property>
<property name= "hibernate.proxool.xml "> proxool.xml </property>
<property name= "connection.provider_class "> org.hibernate.connection.ProxoolConnectionProvider </property>
<property name= "hibernate.show_sql "> false </property>
<property name= "hibernate.dialect "> org.hibernate.dialect.MySQLInnoDBDialect </property>
<property name= "hibernate.connection.driver_class "> com.mysql.jdbc.Driver </property>
<!-- Mapping files -->
<mapping resource= "com/tcs/bean/entitybean/Employee.hbm.xml " />
</session-factory>
</hibernate-configuration>


[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> dbpool </alias>
<!--proxool只能管理由自己产生的连接-->
<driver-url>
jdbc:mysql://127.0.0.1:3306/tcs?useUnicode=true&characterEncoding=UTF-8
</driver-url>
<driver-class> com.mysql.jdbc.Driver </driver-class>
<driver-properties>
<property name= "user " value= "root " />
<property name= "password " value= "123123 " />
</driver-properties>
<!-- proxool自动侦察各个连接状态的时间间隔(毫秒),侦察到空闲的连接就马上回收,超时的销毁-->
<house-keeping-sleep-time> 90000 </house-keeping-sleep-time>
<!-- 最少保持的空闲连接数-->
<prototype-count> 5 </prototype-count>


<!-- 允许最大连接数,超过了这个连接,再有请求时,就排在队列中等候,最大的等待请求数由maximum-new-connections决定-->
<maximum-connection-count> 100 </maximum-connection-count>
<!-- 最小连接数-->
<minimum-connection-count> 10 </minimum-connection-count>
</proxool>
</something-else-entirely>

[数据库工厂类]代码如下:

public class HibernateFactory {
private static final SessionFactory sessionFactory;
static {
try {
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
public static final ThreadLocal session = new ThreadLocal();
public static Session currentSession() {
Session s = (Session) session.get();
// Open a new Session, if this Thread has none yet
if (s == null) {
s = sessionFactory.openSession();
session.set(s);
}
return s;
}
public static void closeSession() {
Session s = (Session) session.get();
if (s != null)
s.close();
session.set(null);
}
}

[解决办法]
找不到proxool.xml 现在这两个配置文件怎么放的
[解决办法]
跟这个有关么?
hibernate.proxool.existing_pool true
我看你没有这个设置吧?
[解决办法]
晕啊
[解决办法]
不能打开连接。不知道什么原因,没接触过。在重新配置一下吧

读书人网 >Java Web开发

热点推荐