SSH2 dao层 this.getSession()和 this.getHibernateTemplate()都为空 100
Spring配置文件为:<beanid="dataSource"class="com.mchange.v2.c3p0.ComboPooledDataSource"dest...
Spring配置文件为:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass">
<value>com.microsoft.sqlserver.jdbc.SQLServerDriver</value>
</property>
<property name="jdbcUrl">
<value>jdbc:sqlserver://localhost:1433;databaseName=bysy</value>
</property>
<property name="user">
<value>sa</value>
</property>
<property name="password">
<value>123456</value>
</property>
<property name="minPoolSize">
<value>15</value>
</property>
<property name="acquireIncrement">
<value>5</value>
</property>
<property name="maxPoolSize">
<value>25</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 把数据源注入给session工厂-->
<property name="dataSource">
<ref bean="dataSource" />
</property>
<!-- 配置hibernate属性 -->
<property name="hibernateProperties">
<props>
<!-- dialect参数必须配置,用于Hibernate使用的不同数据库类型 -->
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>
com/bagutech/webpage/model/WAdmininfo.hbm.xml
</value>
<value>
com/bagutech/webpage/model/WCategoryinfo.hbm.xml
</value>
</list>
</property>
</bean>
dao层为:
public WAdmininfo findLogin(String name ,String pwd) throws Exception {
String hql="select * from WAdmininfo where AUname = "+ name +" and APassword = "+pwd;
Query query = this.getSession().createQuery(hql);
return (WAdmininfo)query.uniqueResult();
}
**我的dao和是impl写反了,dao是实现类,impl是接口;
图片为报错信息: 展开
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass">
<value>com.microsoft.sqlserver.jdbc.SQLServerDriver</value>
</property>
<property name="jdbcUrl">
<value>jdbc:sqlserver://localhost:1433;databaseName=bysy</value>
</property>
<property name="user">
<value>sa</value>
</property>
<property name="password">
<value>123456</value>
</property>
<property name="minPoolSize">
<value>15</value>
</property>
<property name="acquireIncrement">
<value>5</value>
</property>
<property name="maxPoolSize">
<value>25</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 把数据源注入给session工厂-->
<property name="dataSource">
<ref bean="dataSource" />
</property>
<!-- 配置hibernate属性 -->
<property name="hibernateProperties">
<props>
<!-- dialect参数必须配置,用于Hibernate使用的不同数据库类型 -->
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>
com/bagutech/webpage/model/WAdmininfo.hbm.xml
</value>
<value>
com/bagutech/webpage/model/WCategoryinfo.hbm.xml
</value>
</list>
</property>
</bean>
dao层为:
public WAdmininfo findLogin(String name ,String pwd) throws Exception {
String hql="select * from WAdmininfo where AUname = "+ name +" and APassword = "+pwd;
Query query = this.getSession().createQuery(hql);
return (WAdmininfo)query.uniqueResult();
}
**我的dao和是impl写反了,dao是实现类,impl是接口;
图片为报错信息: 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询