hibernate配置proxool出错

sjzpc040529 sjzpc040529 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="proxool.pool_alias">proxoolPool</property>
<property name="proxool.xml">proxoolconf.xml</property>
<property name="connection.provider_class">org.hibernate.connection.ProxoolConnectionProvider</property>
<property name="connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
</session-factory>
</hibernate-configuration>

proxool.xml
<?xml version='1.0' encoding='UTF-8'?>
<!--the proxool configuratin can be embedded within your own application's.
Anything outside the "proxool" tag is ignored. -->
<something-else-entirely>
<proxool>
<alias>proxoolPool</alias>
<driver-url>jdbc:microsoft:sqlserver://localhost:1433</driver-url>
<driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
<driver-properties>
<property name="username" value="sa"></property>
<property name="password" value="sa"/>
</driver-properties>
<house-keeping-sleep-time>90000</house-keeping-sleep-time>
<maximum-new-connections>20</maximum-new-connections>
<prototype-count>5</prototype-count>
<maximum-connection-count>100</maximum-connection-count>
<minimum-connection-count>10</minimum-connection-count>
</proxool>
</something-else-entirely>

hibernate工程类
HibernateSessionFactory.java
package com.zsw.DB.Factory;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
public class HibernateSessionFactory {
// 配置文件路径
private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";
// 单体session线程
private static final ThreadLocal<Session> threadLocal = new ThreadLocal<Session>();
private static Configuration configuration = new Configuration();
// 工厂类
private static org.hibernate.SessionFactory sessionFactory;
private static String configFile = CONFIG_FILE_LOCATION;
static {
try {
configuration.configure(configFile);
sessionFactory = configuration.buildSessionFactory();
} catch (Exception e) {
System.err.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
private HibernateSessionFactory() {
}
/**
* @返回 ThreadLocal Session 实例
* @return Session
* @throws HibernateException
*/
public static Session getSession() throws HibernateException {
Session session = (Session) threadLocal.get();

if (session == null || !session.isOpen()) {
if (sessionFactory == null) {
rebuildSessionFactory();
}
session = (sessionFactory != null) ? sessionFactory.openSession()
: null;
threadLocal.set(session);
}

return session;
}

/**
* @关闭单个ThreadLocal Session 实例
*
* @throws HibernateException
*/
public static void closeSession() throws HibernateException {
Session session = (Session) threadLocal.get();
threadLocal.set(null);

if (session != null) {
session.close();
}
}
}

测试类Test.java
package com.zsw.DB.Factory;
public class Test {
public static void main(String[] args) {
HibernateSessionFactory.getSession();
System.out.println("=========");
}

}
...全文

相关推荐

Spring+Hibernate+Proxool连接池

是spring中引入连接池 博文链接:https://yanghaiskys.iteye.com/blog/215424

weixin_38669628

IOIF基于开源技术的JAVA开发框架

软件开发思想从面向过程到OOP面向对象,再到AOP面向方面,每一次新思想的提出都能够降低对程序员的要求,加快软件开发的进度。该框架在实现的过程中提出一个新的概念IOP“面向项目的开发”。在这个思想的指导下,结合当前流行的框架与技术,开发实现了一个面向项目的集成框架,命名为IOIF。IOIF避免了对某个项目的依赖,使之成为一个主流B/S与C/S项目通用的框架。IOIF的提出是为了避免每个项目重新考虑与实现框架,在提高项目开发进度的同时,框架在设计上也封装了一些程序员容易出错的地方,使整个项目更安全更健壮。 IOIF以EXTJS为前端,以Spring、Struts、Hibernate为后端,整合了Proxool、Log4j、Quartz、Oscache、Castor、Memcached、redis等优秀的开源软件。 支持Tomcat6及Resin3等应用服务器,支持Oracle、MYSQL等数据库。IOIF不依赖于应用服务器可支持J2SE的开发。 实现的主要功能有:客户端Frame、客户端VAD、异常处理、错误处理、AOP日志管理、计划任务、操作日志管理、数据分页功能、线程池管理、内存缓存管理。主要工具有:系统日志工具、应用属性配置工具、系统属性配置工具、TOOLS工具、邮件发送工具、MD5工具等。

wtd1218

Proxool 在 Hibernate 中的典型配置

Proxool 是一种 Java 数据库连接池技术。本材料详细描述Proxool的配置过程。

hjb88

配置Hibernate使用Proxool连接池

NULL 博文链接:https://12345678.iteye.com/blog/718296

weixin_38669628

Hibernate Proxool连接池配置总结及常遇问题

Hibernate Proxool连接池配置总结及常遇问题

落叶神冲
评论 7
收藏 已收藏
分享
返回顶部
sjzpc040529
Web 开发 81,108 成员 341,721 内容