日期:2014-05-20 浏览次数:20627 次
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"></property> <property name="url" value="jdbc:jtds:sqlserver://127.0.0.1:1433;DatabaseName=ormerp_supply"></property> <property name="username" value="sa"></property> <property name="password" value="qwerty12345"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.SQLServerDialect </prop> </props> </property> <property name="mappingResources"> <list> <value> com/User.hbm.xml </value> </list> </property> </bean> <bean id="userDao" class="com.UserDaoImpl"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> </beans>
package com; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; public class UserDaoImpl extends HibernateDaoSupport implements UserDao { @Override public void login() { // TODO Auto-generated method stub System.out.println(this.getSessionFactory()); } }