问题描述
<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.0.xsd"><beanid="dataSource"class="org.apache.commons.dbcp.BasicDataSource"><propertyname="driverClassName"value="com.microsoft.sqlserver.jdbc.SQLServerDriver"></property><propertyname="url"value="jdbc:sqlserver://localhost:1433;databaseName=OfficeAppliction"></property><propertyname="username"value="sa"></property><propertyname="password"value="ma860709"></property></bean><beanid="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><propertyname="dataSource"><refbean="dataSource"/></property><propertyname="hibernateProperties"><props><propkey="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop></props></property></bean><beanid="userDAO"class="db.imp.userDAOImpl"><propertyname="sessionFactory"ref="sessionFactory"></property></bean></beans>
解决方案
解决方案二:
packagedb.imp;importjava.util.List;importorg.hibernate.Query;importorg.springframework.orm.hibernate3.support.HibernateDaoSupport;importpojo.CheckType;importpojo.UsersInfo;importdb.dao.userDAO;publicclassuserDAOImplextendsHibernateDaoSupportimplementsuserDAO{publicvoidadd(UsersInfouser){this.getHibernateTemplate().save(user);}publicvoiddel(UsersInfouser){//TODOAuto-generatedmethodstub}publicUsersInfoget(Stringid){UsersInfouser=(UsersInfo)this.getHibernateTemplate().get(UsersInfo.class,id);returnuser;}publicUsersInfologin(StringuserName,StringuserPassword){Stringhql="fromUsersInfowhereuserName=?anduserPwd=?";Queryquery=this.getSession().createQuery(hql);query.setString(0,userName);query.setString(1,userPassword);UsersInfouser=(UsersInfo)query.uniqueResult();returnuser;}publicList<UsersInfo>search(){//TODOAuto-generatedmethodstubreturnnull;}publicvoidupdate(UsersInfouser){}
解决方案三:
兄弟,你撒问题哦???
解决方案四:
就是我这样配有错吗?为什么会报我错Exceptioninthread"main"java.lang.NullPointerExceptionatorg.springframework.orm.hibernate3.support.HibernateDaoSupport.getSession(HibernateDaoSupport.java:140)atdb.imp.userDAOImpl.login(userDAOImpl.java:31)atdb.imp.userDAOImpl.main(userDAOImpl.java:52)
解决方案五:
谁能帮帮我?
解决方案六:
学习
解决方案七:
Queryquery=this.getSession().createQuery(hql);获取不到session