spring整合struts,hibernate annotation(pool数据池,sqlserver2005数据库)

11 篇文章 0 订阅
7 篇文章 0 订阅

proxool.xml(加jtds.jar+proxool-0.9.1.jar+proxool-cglib.jar)

<?xml version="1.0" encoding="UTF-8"?>
<something-else-entirely>
  <proxool>
    <alias>av</alias>
   <!--
    <driver-url>jdbc:sqlserver://localhost:1433;databaseName=novel9</driver-url>
    <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
    <driver-properties>
      <property name="user" value="sa"/>
      <property name="password" value="sa"/>
    </driver-properties>
     -->  
 <driver-url>jdbc:jtds:sqlserver://localhost:1433;databaseName=novel9</driver-url>
    <driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
    <driver-properties>
      <property name="user" value="sa"/>
      <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>
 <check-valid-connection-sql>select * from t_user</check-valid-connection-sql>
<minimum-connection-count>10</minimum-connection-count>
</proxool>
</something-else-entirely>

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/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">


  
  

 <servlet>
    <servlet-name>ServletConfigurator</servlet-name>
    <servlet-class>org.logicalcobwebs.proxool.configuration.ServletConfigurator</servlet-class>
    <init-param>
    <param-name>xmlFile</param-name>
    <param-value>WEB-INF/classes/proxool.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
  
  <error-page>
        <error-code>404</error-code>
        <location>/404.jsp</location>
    </error-page>
<!--<servlet>   
    <servlet-name>Admin</servlet-name>   
    <servlet-class> org.logicalcobwebs.proxool.admin.servlet.AdminServlet </servlet-class>   
</servlet>   
  
<servlet-mapping>   
    <servlet-name>Admin</servlet-name>   
    <url-pattern>/Admin </url-pattern>   
</servlet-mapping>  
-->
<context-param>
	<param-name>contextConfigLocation</param-name>
		<param-value>WEB-INF/classes/beans.xml</param-value>
	</context-param>
   <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
   
   
   <display-name>Struts Blank</display-name> 
  <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>
  
  <welcome-file-list>
    <welcome-file>/WEB-INF/BackView/login.jsp</welcome-file>
  </welcome-file-list>
  

  
</web-app>

beans.xml



<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-2.5.xsd">
           
           
  <context:annotation-config/>
	  <!-- 自动扫描管理Bean,注解方式进行创建 -->
	  <context:component-scan base-package="com"/>
 
 <bean id="dataSource"     class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName">     
    <value>org.logicalcobwebs.proxool.ProxoolDriver</value>     
        </property>     
        <property name="url">     
            <value>proxool.av</value>     
        </property>     
    </bean>     
    <bean id="sessionFactory"     
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">     
        <property name="dataSource">     
            <ref bean="dataSource" />     
        </property>     
        <property name="hibernateProperties">     
            <props>     
                <prop key="hibernate.dialect">     
                   org.hibernate.dialect.SQLServerDialect   
                </prop>     
                <prop key="hibernate.connection.autocommit">true</prop>     
                <prop key="hibernate.show_sql">true</prop>     
                <prop key="hibernate.connection.release_mode">     
                     after_statement      
                </prop>     
            </props>     
        </property>     
 	<property name="annotatedClasses">
			<list>
				<value>com.model.user</value>
			</list>
		</property>
    </bean>     

<bean id="hibernateTemplate"     
        class="org.springframework.orm.hibernate3.HibernateTemplate">     
        <property name="sessionFactory">     
            <ref bean="sessionFactory" />     
        </property>     
    </bean>
    

</beans>




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值