首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

[]用hibernate插入表单数据报错.

2013-09-11 
[求助]用hibernate插入表单数据报错..工具:myeclipse数据库:mysql架构是:Struts+Sping+Hibernate项目:学生

[求助]用hibernate插入表单数据报错..
工具:myeclipse
数据库:mysql
架构是:Struts+Sping+Hibernate
项目:学生选课系统

//addstu.jsp

form是:xh,password,xm,yx,major

然后填充到AddstuForm

_____________________________________________
//AddstuFormAction的execute()方法

AddstForm   addstForm   =   (AddstForm)   form;//   TODO   Auto-generated   method   stub
Student   stu=new   Student();

stu.setXh(addstForm.getXh());
stu.setPassword(addstForm.getPassword());
stu.setXm(addstForm.getXm());
stu.setYx(addstForm.getYx());
stu.setMajor(addstForm.getMajor());
studentdao.save(stu);

return   mapping.findForward( "succeed ");
______________________________________


//StudentDAO.java

        public   void   save(Student   transientInstance)   {
                log.debug( "saving   Student   instance ");
                try   {
                System.out.println( "ssssssssss ");
                        getHibernateTemplate().save(transientInstance);
                        log.debug( "save   successful ");
                }   catch   (RuntimeException   re)   {
                        log.error( "save   failed ",   re);
                        throw   re;
                }
        }

---------------------

★tomcat可以执行到System.out.println( "ssssssssss ");
输出ssssssssss


type   Exception   report

message  

description   The   server   encountered   an   internal   error   ()   that   prevented   it   from   fulfilling   this   request.

exception  

javax.servlet.ServletException:   Hibernate   operation:   could   not   insert:   [org.rockie.dao.Student];   bad   SQL   grammar   [insert   into   stucourse__student   (XH,   PASSWORD,   XM,   YX,   MAJOR)   values   (?,   ?,   ?,   ?,   ?)];   nested   exception   is   java.sql.SQLException:   Base   table   or   view   not   found,     message   from   server:   "Table   'stucourse.stucourse__student '   doesn 't   exist "
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root   cause  

org.springframework.jdbc.BadSqlGrammarException:   Hibernate   operation:   could   not   insert:   [org.rockie.dao.Student];   bad   SQL   grammar   [insert   into   stucourse__student   (XH,   PASSWORD,   XM,   YX,   MAJOR)   values   (?,   ?,   ?,   ?,   ?)];   nested   exception   is   java.sql.SQLException:   Base   table   or   view   not   found,     message   from   server:   "Table   'stucourse.stucourse__student '   doesn 't   exist "


org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:224)
org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424)
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:411)
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:371)
org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:614)
org.rockie.dao.StudentDAO.save(StudentDAO.java:36)
org.rockie.action.AddstAction.execute(AddstAction.java:58)
org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note   The   full   stack   trace   of   the   root   cause   is   available   in   the   Apache   Tomcat/5.5.17   logs.




[解决办法]
找不到表 'stucourse.stucourse__student '
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

热点排行