| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1175 人关注过本帖
标题:struts+hibernate 问题。。
取消只看楼主 加入收藏
zhangjipeng
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2007-11-6
收藏
 问题点数:0 回复次数:1 
struts+hibernate 问题。。
错误:
     javax.servlet.ServletException: could not execute query
 
action文件:
     
    public ActionForward execute (ActionMapping mapping,  
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response) {
        IndexForm indexform = new IndexForm();
        Session session = HibernateSessionFactory.getSession();
        String hql="from welcome i where i.name="+request.getParameter("name")+" and i.password="+request.getParameter("password");
        Query query = session.createQuery(hql);
        System.out.println(hql);
        List list = null;
        list = query.list();
        System.out.println(list.size());
        if(list.isEmpty())
            return mapping.findForward("no");
        else
            return mapping.findForward("ok");
    }

奇怪的是我在页面上输入一条数据库里没有的数据他会正确forword到no,如果数据库里有数据他就报could not execute query 错误。请教了。。。。。
搜索更多相关主题的帖子: hibernate struts 
2007-12-25 10:54
zhangjipeng
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2007-11-6
收藏
得分:0 
问题已解决。。自己太粗心。!hql格式错误:
 hql="from welcome i where i.name='"+request.getParameter("name")+" 'and i.password='"+request.getParameter("password")"'"; 加上单引号就OK了。。。
2007-12-25 11:46
快速回复:struts+hibernate 问题。。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015838 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved