ssh框架-SSH框架整合的注册登陆例子,hql老是报错。注册可以运行,求大侠解救

问题描述

SSH框架整合的注册登陆例子,hql老是报错。注册可以运行,求大侠解救

这个是登陆源码

 public boolean loginObject(User user) throws HibernateException{
        System.out.println("6666666666666");
        //String hql=("from User u where?u.username=? and u.password=?",user.getUsername(),user.getPassword());
        //System.out.println("from User u where?u.username=? and u.password=?",user.getUsername(),user.getPassword());
        List<User> userlist=getHibernateTemplate().find("from User u where?u.username=? and u.password=?",user.getUsername(),user.getPassword());
        if(userlist.size()>0)
            return true;
        else
            return false;
    }

这个是报的错

 org.hibernate.hql.ast.QuerySyntaxException: unexpected token: where u near line 1, column 32 [from com.ynwi.ssh.beans.User u where u.username=? and u.password=?]
    org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
    org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
    org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:82)
    org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:286)
    org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:184)
    org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138)
    org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
    org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
    org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:124)
    org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
    org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
    org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1770)
    org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:914)
    org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:912)
    org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
    org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
    org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:912)
    com.ynwi.ssh.daoImpl.UserDao.loginObject(UserDao.java:26)
    com.ynwi.ssh.serviceImpl.UserManagerImpl.login(UserManagerImpl.java:30)
    com.ynwi.ssh.action.LoginAction.execute(LoginAction.java:24)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:606)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:270)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:498)
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)

解决方案

你不能这样给前边两个问号注值 有方法可以的 .setString(第几个问号,值)

时间: 2024-10-31 15:01:44

ssh框架-SSH框架整合的注册登陆例子,hql老是报错。注册可以运行,求大侠解救的相关文章

ssh+dwz-DWZ框架分页属性重名,导致父页面刷新报错!在线等!急~~~

问题描述 DWZ框架分页属性重名,导致父页面刷新报错!在线等!急~~~ SSH+DWZ 依次操作或点击完选项卡2和选项卡3,再(手动或程序)刷新父页面"修改"会出现图1错误,屏蔽选项卡2或3中的红色框的内容或修改成其他名字则不会报错,但是没了红色框内容则分页功能用不了,尝试修改过js,然后再刷新"修改"选卡不出错了但只能成功分页却不能选择第几页或下一页,求知道的大大指导一下在线等~!!!!!! 解决方案 请点开全部展开查看,附上图1-图3 解决方案二: 请点开全部展

主键-坐等求救,java用ssh的时候,Gson解析json有外键的时候报错

问题描述 坐等求救,java用ssh的时候,Gson解析json有外键的时候报错 解析json是用的gson,实体类涉及到三张表三个类,之间的关系是: C表的一个字段是外键,为A表的主键 C表的另一个字段是外键,为B表的主键 转json的时候报如下异常,该怎么做,请具体一点. 这是多对多的关系吧? java.lang.UnsupportedOperationException: Attempted to serialize java.lang.Class: org.hibernate.proxy

初学java,自己用java写了一个简单的注册登录程序,没报错但有问题,希望能帮忙指点。

问题描述 初学java,自己用java写了一个简单的注册登录程序,没报错但有问题,希望能帮忙指点. import java.util.Scanner; class Yanzheng{ private String n; private String p; public void setNa(String na){ this.n = na; } public void setPa(String pa){ this.p = pa; } public String getNa(){ return n;

传智播客网上图书商城项目,注册时发送邮箱验证码报错,求助

问题描述 传智播客网上图书商城项目,注册时发送邮箱验证码报错,求助 严重: Servlet.service() for servlet UserServlet threw exception java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at cn.itcast.servlet.BaseServlet.service(BaseServlet.java:60) at javax.servlet.htt

ubuntu登陆glade时,报错怎么个情况

问题描述 ubuntu登陆glade时,报错怎么个情况 (glade:32828): Gtk-WARNING **: Content added to the action area of a dialog using header bars (glade:32828): Gtk-WARNING **: Content added to the action area of a dialog using header bars GladeUI-Message: 20 missing displa

Hibernate实现注册,注册一个账号后得重启服务器才能注册第二个,不然报错

问题描述 Hibernate实现注册,注册一个账号后得重启服务器才能注册第二个,不然报错 public class RegisterAction extends ActionSupport{ private static final long serialVersionUID = 1L; User user = new User(); public User getUser() { return user; } public void setUser(User user) { this.user

khj-spring整合quartz定时任务报错,请大神们解救

问题描述 spring整合quartz定时任务报错,请大神们解救 web.xml中的配置 spring_mvcorg.springframework.web.servlet.DispatcherServlet contextConfigLocationclasspath:applicationContext spring_mvc/ applicationContext.xml的配置 <!-- 要调用的工作类 --> <!-- 定义调用对象和调用对象的方法 --> <!-- 调

我使用cxf和spring整合发布WebService,tomcat上没有报错但是就不访问wsdl

问题描述 我使用cxf和spring整合发布WebService,tomcat上没有报错但是就不访问wsdl No cxf.xml configuration file detected, relying on defaults.在运行tomcat时报这个

linux下整合Apache+subversion加载mod_dav_svn.so报错

问题描述 linux下整合Apache+subversion加载mod_dav_svn.so报错 报错信息: httpd: Syntax error on line 219 of /etc/httpd/conf/httpd.conf: Cannot load /etc/httpd/modules/mod_dav_svn.so into server: /usr/local/subversion/lib/libsvn_subr-1.so.0: undefined symbol: apr_hash_