问答详情
源自:2-3 用户业务逻辑接口和类

控制台没有输出错误信息,但是junit就是棕色的,运行不成功

package hlx.DaoImpl;


 


import java.util.List;


import org.hibernate.Query;

import org.hibernate.Session;

import org.hibernate.Transaction;


import po.HibernateSessionFactory;


import hlx.Dao.UsersDao;

import hlx.bean.Userinfo;


public class UsersDaoImpl implements UsersDao{


public boolean userLogin(Userinfo u) {

// TODO Auto-generated method stub

Transaction tr = null;

String hql ="";

try {

Session session = HibernateSessionFactory.getSession();

hql="from Userinfo where userName=? and userPassword =?";

tr = session.beginTransaction();

Query query = session.createQuery(hql);

query.setParameter(0, u.getUserName());

query.setParameter(1, u.getUserPassword());

List list = query.list();

tr.commit();

session.close();

if(list.size()>0){

return true;

}else{

return false;

}

} catch (Exception e) {

// TODO: handle exception

e.printStackTrace();

return false;

}finally{

if(tr!=null){

tr=null;  //释放资源


}

}

}


}


提问者:慕仙9202759 2016-06-09 11:16

个回答

  • 慕仙9202759
    2016-06-09 11:56:19

    找出问题所在了。java.lang.nosuchmethoderror;antlr.collections.AST.getLinew()I,解决办法,在myeclipse下,windows-》preference——》project capabilities-》remove掉struts2的 antlr2.7.2 。jar包就好了