配置proxool,加载了proxool的包,一直报错,看错误提示,说不能实例化ProxoolConnectionProvider,查hibernate核心包,里面connection里确实没有这个东东,后来才知道要加载一个hibernate-proxool包才行,可所有配置的教程都没提过,是不是这是该默认知道的东西,我了解的东西太少了?
在maven里加入这个包的最新版本4.1,却发现还是不行,解包一看,4.1里面ProxoolConnectionProvider的pakage路径换了,再晕,这也没事换换啊。因为前面的东西有基于hibernate 3.5.1的,干脆换成3.5.1版本,OK了。
现在将我的spring+struts+jpa(hibernate)+proxool的配置文件贴出来,希望对大家有用,不过目前我的配置会报一个jndi找不到路径名的警告,但不影响运行,这个问题还待解决,见我博客上一篇文章,求解答啊:http://blog.csdn.net/yyzhq/article/details/7484620
WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="struts2springjpa" version="2.5">
<display-name>Struts 2 Spring JPA Example</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<filter-class>
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
WEB-INF/classes/applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- scans the classpath for annotated components (including @Repostory
and @Service that will be auto-registered as Spring beans -->
<context:component-scan base-package="com.yesrj.ppm.global.system" />
<!-- methods or classes needing to run in a complete transaction will
be annotated with Transactional -->
<tx:annotation-driven />
<!-- Creates a data source that can provide a connection to in-memory embedded database populated
with test data
see: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/ch12s08.html
-->
<!-- This will ensure that hibernate or jpa exceptions are automatically translated into
Spring's generic DataAccessException hierarchy for those classes annotated with Repository
For example see PersonDaoJpa-->
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
<!-- JPA Entity Manager Factory -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceXmlLocation" value="META-INF/persistence.xml" />
<property name="persistenceUnitName" value="springJpaPersistenceUnit" />
</bean>
<!-- bean post-processor for JPA annotations -->
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<!-- Transaction Config -->
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<!-- use declarative transaction management -->
<tx:annotation-driven transaction-manager="transactionManager"/>
</beans>
WEB-INF/classes/struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<package name="system" extends="struts-default">
<interceptors>
<interceptor-stack name="appDefaultStack">
<interceptor-ref name="defaultStack">
<param name="exception.logEnabled">true</param>
<param name="exception.logLevel">ERROR</param>
</interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="appDefaultStack" />
<global-results>
<result name="error">/error.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception"
result="error" />
</global-exception-mappings>
<action name="personFinder"
class="com.yesrj.plm2.global.system.action.PersonFinder" method="execute">
<result name="success">/personinfo.jsp</result>
</action>
<action name="allPersonsFinder"
class="com.yesrj.plm2.global.system.action.AllPersonsFinder" method="execute">
<result name="success">/personsinfo.jsp</result>
</action>
<action name="*PersonUpdate"
class="com.yesrj.plm2.global.system.action.PersonUpdater" method="{1}">
<result name="input">/inputpersonupdate.jsp</result>
<result name="success">/personupdated.jsp</result>
</action>
<action name="personDelete"
class="com.yesrj.plm2.global.system.action.PersonDeleter" method="execute">
<result name="success">/persondeleted.jsp</result>
</action>
<action name="*PersonSave" class="com.yesrj.plm2.global.system.action.PersonSaver"
method="{1}">
<result name="input">/inputpersonsave.jsp</result>
<result name="success">/personsaved.jsp</result>
</action>
</package>
</struts>
META-INF/persistence.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistencehttp://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<!-- this persistence unit is for the web application -->
<persistence-unit name="springJpaPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>java:comp/env/jdbc/yespm</non-jta-data-source>
<class>com.yesrj.ppm.global.system.model.Person</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.use_sql_comments" value="true" />
<property name="hibernate.connection.provider_class" value="org.hibernate.connection.ProxoolConnectionProvider"/>
<property name="hibernate.proxool.pool_alias" value="MysqlPool"/>
<property name="hibernate.proxool.xml" value="proxool.xml"/>
</properties>
</persistence-unit>
</persistence>
WEB-INF/classes/proxool.xml
<?xml version="1.0" encoding="utf-8"?>
<something-else-entirely>
<proxool>
<alias>MysqlPool</alias>
<driver-url>jdbc:mysql://localhost:3306/yespm</driver-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver-properties>
<property name="user" value="root" />
<property name="password" value="root" />
</driver-properties>
<house-keeping-sleep-time>90000</house-keeping-sleep-time>
<prototype-count>5</prototype-count>
<maximum-connection-count>100</maximum-connection-count>
<minimum-connection-count>10</minimum-connection-count>
</proxool>
</something-else-entirely>
分享到:
相关推荐
然而,在使用过程中,开发者可能会遇到各种配置问题,其中之一就是"找不到ProxoolConnectionProvider的问题"。这个问题通常是由于Hibernate4与Proxool数据源集成时的配置不当或版本不兼容所引起的。 Proxool是...
在上述配置中,我们通过`hibernate.proxool.properties`指定了Proxool的配置文件路径,`hibernate.proxool.pool_alias`设置了连接池的别名,这个别名需要与Proxool配置文件中的alias一致。 接下来,我们需要创建...
标题中的“hibernate3+ proxool-0.9.1配置”涉及到的是在Java开发中,使用Hibernate3 ORM框架与Proxool连接池的整合配置。Hibernate3是一款流行的持久层框架,它允许开发者用面向对象的方式来操作数据库,而Proxool...
这有助于我们更好地理解其工作流程,从而在遇到问题时能够迅速定位并解决。 "工具" 标签则意味着 Proxool 是一个实用的开发工具,可以集成到任何 Java 应用中,简化数据库连接的管理。Proxool 提供了一些监控和诊断...
项目实用的proxool连接池配置文件,每个标签都有注释,可以直接拿来使用
为了在C#中有效地使用Proxool,开发者需要确保正确地导入了Java库,并且在代码中创建和配置Proxool的连接池实例。这通常涉及到初始化连接池配置,例如定义连接池大小、空闲超时时间、测试SQL语句等。然后,需要编写...
**Hibernate Proxool连接池配置详解** 在Java应用程序中,数据库连接池是管理数据库连接的一种高效...理解并掌握Proxool的各项配置参数,以及在遇到问题时能及时诊断和解决,能够帮助我们构建更加稳定和高效的系统。
Spring中使用proxool的配置 Spring中使用proxool的配置Spring中使用proxool的配置 Spring中使用proxool的配置
**Proxool 连接池实例详解** 在Java应用程序中,数据库连接管理是性能优化的关键环节之一。Proxool是一个轻量级的、开源的JDBC连接池,它提供了高效且灵活的数据库连接管理方案。Proxool允许开发者通过配置文件来...
这样不仅减少了数据库连接的创建和销毁开销,还能防止过多连接导致的资源耗尽问题。 **配置Proxool** 1. **添加依赖**: 首先,你需要在项目中引入Proxool的库。如果你使用的是Maven,可以在pom.xml文件中添加以下...
**Proxool配置参数说明** Proxool是一个开源的数据库连接池实现,它提供了一种灵活的方式来管理和控制数据库连接。在使用Proxool时,理解其配置参数是至关重要的,这些参数可以调整连接池的行为,以适应不同应用...
### Proxool配置详解 #### 一、简介 Proxool是一个开源的Java数据库连接池管理器,由Joe Doherty开发并维护。它能够帮助应用程序有效地管理和复用数据库连接,减少频繁创建和销毁数据库连接所带来的性能开销,从而...
proxool-0.9.1(my).jar 包是我修改了proxool-0.9.1后的jar包,修改后可以完全支持spring配置,并添加了charSet配置属性,用于配置数据库链接的设置默认字符集,并且解决了proxool数据库连接池报如下错误的问题:...
总的来说,Proxool作为一款优秀的数据库连接池,不仅提供了高效的连接管理,还内置了强大的监控功能,帮助开发者优化数据库访问性能,及时发现和解决问题。通过`testProxool`实例,我们可以更好地理解和运用Proxool...
### Proxool连接池配置详解 #### 一、概述 ...以上配置提供了一个完整的Proxool连接池配置实例,涵盖了关键配置项及其应用场景。合理配置这些参数可以帮助优化数据库访问性能,并确保系统的稳定运行。
通过阅读源码,开发者可以深入理解Proxool的工作原理,学习如何配置和优化连接池,甚至根据需求进行定制化开发。 描述中的"Java实现oracle proxool 单态的例子"是指使用Java编程语言实现Oracle Proxool的一个单例...
1. **配置文件**:Proxool通常通过XML配置文件进行初始化设置,例如`proxool.xml`。在这个文件中,你可以定义连接池的大小、超时时间、空闲连接检查频率等关键参数。 2. **连接池大小**:`proxy-limit`属性用于设定...
最后,Web应用程序通常还需要在`web.xml`中配置Spring的DispatcherServlet以及相关的监听器,以初始化和销毁Spring上下文。这部分配置与Proxool的使用直接关系不大,但确保了Spring可以正常运行。 总结来说,Spring...
7. **监控与日志**:Proxool提供了监控和日志功能,可以通过配置相应的属性来开启,帮助开发者了解连接池的使用情况,及时发现和解决问题。 通过以上配置,我们就可以在Spring应用中顺利使用Proxool作为数据库连接...