public boolean login(String userName, String userPWD) {
List list = null;
final String sql = "select * from [nice_dw].[dbo].USERINFO u where u.user_login_name='"+userName_temp+"' and u.user_pwd='"+userPWD_temp+"'";
list = getHibernateTemplate().find(sql);
log.info(sql);
if (!list.isEmpty()) {
return true;
}
return false;
}
报错: org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: * near line 1, column 8 [select * from [nice_dw].[dbo].USERINFO u where u.user_login_name='2' and u.user_pwd='2']; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: * near line 1, column 8 [select * from [nice_dw].[dbo].USERINFO u where u.user_login_name='2' and u.user_pwd='2']
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:642)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:379)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:872)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:864)
at com.egoonet.dao.impl.UserInfoDaoImpl.login(UserInfoDaoImpl.java:177)
at com.egoonet.service.impl.UserInfoServiceImpl.login(UserInfoServiceImpl.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
sql语句正确为什么报错,求解:
------解决方案--------------------------------------------------------
貌似 不认识 * 你把 sql改为
from [nice_dw].[dbo].USERINFO u where u.user_login_name='"+userName_temp+"' and u.user_pwd='"+userPWD_temp+"
------解决方案--------------------------------------------------------
hql是对象查询,[nice_dw].[dbo].USERINFO这个看不懂了.from USERINFO 不行吗