Spring配置代码
- <beans>
- <bean id="dataSource"
- class="org.apache.commons.dbcp.BasicDataSource">
- <property name="driverClassName">
- <value>net.sourceforge.jtds.jdbc.Drivervalue>
- property>
- <property name="url">
- <value>jdbc:jtds:sqlserver://localhost/databasevalue>
- property>
- <property name="username">
- <value>uservalue>
- property>
- <property name="password">
- <value>****value>
- property>
- bean>
- <bean id="sessionFactory"
- class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- <property name="dataSource">
- <ref local="dataSource" />
- property>
- <property name="mappingResources">
- <list>
- <value>com/gridit/qe/bean/DayMaBid.hbm.xmlvalue>
- <value>com/gridit/qe/bean/DayMaInfo.hbm.xmlvalue>
- <value>com/gridit/qe/bean/MaParameter.hbm.xmlvalue>
- <value>com/gridit/qe/bean/MaRegisterInfo.hbm.xmlvalue>
- <value>com/gridit/qe/bean/MmMaBid.hbm.xmlvalue>
- <value>com/gridit/qe/bean/MmMaInfo.hbm.xmlvalue>
- <value>com/gridit/qe/bean/MmRegionInfo.hbm.xmlvalue>
- <value>com/gridit/qe/bean/Plant.hbm.xmlvalue>
- <value>com/gridit/qe/bean/Region.hbm.xmlvalue>
- <value>com/gridit/qe/bean/SysColumnInfo.hbm.xmlvalue>
- <value>com/gridit/qe/bean/YyMaInfo.hbm.xmlvalue>
- <value>com/gridit/qe/bean/DayAreaInfo.hbm.xmlvalue>
- <value>com/gridit/qe/bean/Company.hbm.xmlvalue>
- <value>com/gridit/qe/bean/Area.hbm.xmlvalue>
- list>
- property>
- <property name="hibernateProperties">
- <props>
- <prop key="hibernate.dialect">
- org.hibernate.dialect.SQLServerDialect
- prop>
- <prop key="hibernate.show_sql">trueprop>
- props>
- property>
- bean>
- <bean id="hibernateInterceptor"
- class="org.springframework.orm.hibernate3.HibernateInterceptor">
- <property name="sessionFactory">
- <ref bean="sessionFactory" />
- property>
- bean>
- <bean id="myTransactionManager"
- class="org.springframework.orm.hibernate3.HibernateTransactionManager">
- <property name="sessionFactory">
- <ref local="sessionFactory" />
- property>
- bean>
- <bean id="basedaoTarget" class="com.gridit.qe.dao.BaseDAO">
- <property name="sessionFactory">
- <ref bean="sessionFactory" />
- property>
- bean>
- <bean id="basedao"
- class="org.springframework.aop.framework.ProxyFactoryBean">
- <property name="proxyInterfaces">
- <value>com.gridit.qe.dao.IBaseDAOvalue>
- property>
- <property name="interceptorNames">
- <list>
- <value>hibernateInterceptorvalue>
- <value>basedaoTargetvalue>
- list>
- property>
- bean>
- <bean id="DayMachineBidServiceTarget"
- class="com.gridit.qe.allservice.DayMachineBidServiceImpl">
- <property name="basedao">
- <ref bean="basedao" />
- property>
- bean>
- <bean id="IDayMachineBidService"
- class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
- <property name="transactionManager">
- <ref bean="myTransactionManager" />
- property>
- <property name="target">
- <ref bean="DayMachineBidServiceTarget" />
- property>
- <property name="transactionAttributes">
- <props>
- <prop key="get*">PROPAGATION_SUPPORTSprop>
- <prop key="*">PROPAGATION_REQUIREDprop>
- props>
- property>
- bean>beans>
jndi-xml 代码
- <!-- JNDI数据源 jndiDataSource 的声明 -->
- <bean id="jndiDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
- <property name="jndiName">
- <value>java:comp/env/jdbc/jndidemo</value>
- </property>
- </bean>
同时在数据引用处修改为jndiDataSource....