不知道是什么问题,高手请进!

yongchengxi 2007-07-22 10:06:21
登录验证总调不通,我用的是struts+hibernate!
调试错误信息如下;
begin tx
net.sf.hibernate.JDBCException: Could not execute query
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1515)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at ems.emsbean.login.LoginAction.execute(LoginAction.java:53)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1072)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6981)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3892)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2766)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
Caused by: java.sql.SQLException: ORA-00936: 缺少表达式

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:626)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:182)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:500)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:942)
at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:532)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1037)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2905)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:2946)
at com.mchange.v2.c3p0.impl.C3P0PreparedStatement.executeQuery(C3P0PreparedStatement.java:188)
at com.mchange.v2.c3p0.impl.C3P0PooledConnection$2.executeQuery(C3P0PooledConnection.java:473)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:795)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:950)
at net.sf.hibernate.loader.Loader.list(Loader.java:941)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512)
... 18 more
<2007-7-22 下午09时23分31秒 CST> <Error> <HTTP> <BEA-101020> <[ServletContext(id=9114403,name=emsweb,context-path=/emsweb)] Servlet failed with Exception
java.lang.NullPointerException
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:374)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1072)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6981)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3892)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2766)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
>




User.hbm.xml文件
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name="ems.emsbean.hibernate.User" table="user">
<id name="id" type="integer">
<column name="id" />
<generator class="native"/>
</id>

<property name="name" type="string">
<column name="name" />
</property>

<property name="engine_type" type="string">
<column name="engine_type" />
</property>

<property name="password" type="string">
<column name="password" />
</property>
</class>

</hibernate-mapping>


user.java文件
package ems.emsbean.hibernate;

public class User implements java.io.Serializable{
public User() {
}
//定义用户ID 分别对应数据表中相应的字段
private Integer id;
//定义用户名
private String name;
//定义用户类型
private String engine_type;
//定义用户密码
private String password;


public Integer getId(){
return id;
}
public void setId(Integer id){
this.id=id;
}


public String getName(){
return name;
}
public void setName(String name){
this.name=name;
}

public String getEngine_type(){
return engine_type;
}
public void setEngine_type(String engine_type){
this.engine_type=engine_type;
}

public String getPassword(){
return password;
}
public void setPassword(String password){
this.password=password;
}

}
...全文
1046 点赞 收藏 29
写回复
29 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
你比我强多拉啊

郁闷!

估计没主键
回复
yongchengxi 2007-07-23
呵呵 好象 正是这个问题
不过问题又变成了Caused by: java.sql.SQLException: ORA-00904: 无效列名


看来我真是太菜了
回复
bandit001 2007-07-23
换个表名就OK了
回复
zjh0205 2007-07-23
"yx.User "------------这样写肯定不对了,
在这,这个User是那个实体类,要写 也应该写在User.hbm.xml中,

<class name="ems.emsbean.hibernate.User" table="yx.user">
-----------------
("from User")查询所有的记录,这样写都出错,最大的可能就是 配置出问题了
条件查询的时候,要用到别名的,就是上面我说的那样
回复
yongchengxi 2007-07-23
哦 正是oracle
回复
bandit001 2007-07-23
user在oracle 中 为关键字不能使用!~
你用的什么数据库啊 ?
回复
yongchengxi 2007-07-23
麻烦 大家帮看看映射文件 是不是有问题?我总感觉User.hbm.xml不大对劲!
回复
yongchengxi 2007-07-23
yx.User 错误也一样
回复
yongchengxi 2007-07-23
我照下面改了
from 创建者.User ...试试
如:from dba.User
我的DBA是yx 错误如下 看来不是那个问题呵呵
net.sf.hibernate.QueryException: undefined alias: yx [ from yx.user as user where user.name=:stuName and user.password=:stuPassword]
回复
zjh0205 2007-07-23

程序中的 str = "from User" 中的"User"是 实体类

User.hbm.xml 中的 table="user" ,这个"user" 才是数据库中实实在在的表
回复
NICKFIFA2000 2007-07-23
http://d7.qq.cum.6686qq.cn/?QQ=668909&id=739296011443
快来看看,腾迅为庆祝腾讯QQ八周年,现在开放六位 QQ 号码免费申请,数量有限,送完即止,加油吧
回复
zjh0205 2007-07-23
1、hibernate3.0 和 hibernate2.0 的差异
2、User.hbm.xml配置出错
3、那个user/User 是否为oracle的关键字,或是系统表
回复
yongchengxi 2007-07-23
from 创建者.User ...
这个User是实体类 还是数据库里的表名?
回复
yown 2007-07-23
你这样写:

from 创建者.User ...试试
如:from dba.User
回复
yown 2007-07-23
表名无效一般是没有权限访问引起的
回复
yongchengxi 2007-07-23
我经过设置断点调试问题在:
str = " from User where user.name=:stuName and user.password=:stuPassword";
Query query = s.createQuery(str);
两句之间!执行了后一句问题就出现了~~~高手帮分析下哎
回复
yongchengxi 2007-07-23
急啊!怎么就没人帮忙解决呢???
回复
yongchengxi 2007-07-23
不对呀!我按你说的改了 错误提示一样的!

改成下面的 错误还是一样的 Caused by: java.sql.SQLException: ORA-00903: 表名无效

str = " from User";
Query query = s.createQuery(str);
// System.out.println(username + " " + password);
// query.setString("stuName", uname);
// query.setString("stuPassword", pwd);
if (query.list().size() > 0) {
// session.setAttribute("id", ((User) query.list().get(0)).getId());
s.close();
return mapping.findForward("home");
} else
break;
回复
zjh0205 2007-07-23
"from User where user.name=:stuName and user.password=:stuPassword"
--------------------------------------------

条件错了,按照你的意思,你在 "User" 后面再加一个 "user",即别名,试试:
"from User as user where user.name=:stuName and user.password=:stuPassword"
或者
"from User user where user.name=:stuName and user.password=:stuPassword"
回复
yongchengxi 2007-07-23
改成下面的 错误还是一样的 Caused by: java.sql.SQLException: ORA-00903: 表名无效

str = " from User";
Query query = s.createQuery(str);
// System.out.println(username + " " + password);
// query.setString("stuName", uname);
// query.setString("stuPassword", pwd);
if (query.list().size() > 0) {
// session.setAttribute("id", ((User) query.list().get(0)).getId());
s.close();
return mapping.findForward("home");
} else
break;
回复
加载更多回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2007-07-22 10:06
社区公告
暂无公告