ssh开发- org.hibernate.exception.SQLGrammarException: could not insert:

问题描述

org.hibernate.exception.SQLGrammarException: could not insert:

用的框架 Struts2+Hibernate3+Spring3
数据库为:SQLServer2005
环境是:Myeclipse8.5 服务器为:apache-tomcat-8.0.0-RC1
问题:在我尝试通过struts2 action向数据库插入数据是出现异常。
异常信息如下:
Struts Problem Report
Struts has detected an unhandled exception:

Messages: '107' ????????
could not insert: [com.gxwz.entity.GxUser]
could not insert: [com.gxwz.entity.GxUser]; SQL [insert into 107gxwz.dbo.gx_user (UName, UPwd, UGender, UEmal, URole, UHead, URegDate, ULastLogin, ULastEmit, UPermit, UMobile, UUploadFilesIDs, UDownLoadFileIDs, UUrl, UTopicIDs, URevertIDs) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is org.hibernate.exception.SQLGrammarException: could not insert: [com.gxwz.entity.GxUser]

File: com/microsoft/sqlserver/jdbc/SQLServerException.java
Line number: 216


Stacktraces
org.springframework.dao.InvalidDataAccessResourceUsageException: could not insert: [com.gxwz.entity.GxUser]; SQL [insert into 107gxwz.dbo.gx_user (UName, UPwd, UGender, UEmal, URole, UHead, URegDate, ULastLogin, ULastEmit, UPermit, UMobile, UUploadFilesIDs, UDownLoadFileIDs, UUrl, UTopicIDs, URevertIDs) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is org.hibernate.exception.SQLGrammarException: could not insert: [com.gxwz.entity.GxUser]
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:629)
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:683)
com.gxwz.dao.impl.UserDaoImpl.add(UserDaoImpl.java:30)
com.gxwz.service.impl.UserServiceImpl.add(UserServiceImpl.java:35)
com.gxwz.action.UserAction.addUser(UserAction.java:47)
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:441)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:223)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:107)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:75)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:934)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:90)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:494)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:632)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:281)
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2248)
org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2237)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:724)

org.hibernate.exception.SQLGrammarException: could not insert: [com.gxwz.entity.GxUser]
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:64)
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2176)
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2656)
org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:563)
org.hibernate.impl.SessionImpl.save(SessionImpl.java:551)
org.hibernate.impl.SessionImpl.save(SessionImpl.java:547)
org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:686)
org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:1)
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:683)
com.gxwz.dao.impl.UserDaoImpl.add(UserDaoImpl.java:30)
com.gxwz.service.impl.UserServiceImpl.add(UserServiceImpl.java:35)
com.gxwz.action.UserAction.addUser(UserAction.java:47)
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:441)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
。。。。。。。。。。。。省略。。。。。。
配置文件如下:
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<!-- hibernate配置开始 -->

<!-- 数据源注入session工厂 -->
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

org.hibernate.dialect.SQLServerDialect

update

com/gxwz/entity/GxUser.hbm.xml

<!-- 配置数据库连接池开始-->

value="jdbc:sqlserver://localhost:1433;DatabaseName=107gxwz">

<!-- 配置数据库连接池结束-->
<!-- 声明事物管理器 -->
class="org.springframework.orm.hibernate3.HibernateTransactionManager">

class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">

我的实体映射文件如下:

跪求大虾指点一二。。。。在网上找了好久都没解决。。。。

解决方案

sql语句写错了吧,insert into 107gxwz.dbo.gx_user (UName, UPwd, 。。。。

107gxwz???

时间: 2025-01-02 07:39:12

ssh开发- org.hibernate.exception.SQLGrammarException: could not insert:的相关文章

java-org.hibernate.exception.SQLGrammarException: could not execute query

问题描述 org.hibernate.exception.SQLGrammarException: could not execute query 大神们,看看这maven项目的异常,登陆成功之后,就显示json返回格式异常,query也不能查找了 :[DEBUG] 10:51:35[120906] [ http-5555-3] [000-] [] [AccessControlAdvice] com.wisetop.wtp.core.svc.ServiceException: 按id查找应用系统

org.hibernate.exception.SQLGrammarException: could not execute query

问题描述 StrutsProblemReportStrutshasdetectedanunhandledexception:Messages:ORA-00932:???????:??NUMBER,????BINARYcouldnotexecutequeryFile:oracle/jdbc/driver/SQLStateMapping.javaLinenumber:91-----------------------------------------------------------------

请教:org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch ...

问题描述 org.hibernate.exception.SQLGrammarException:CouldnotexecuteJDBCbatchupdateatorg.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)atorg.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)atorg.hiber

hibernate save-hibernate执行保存对象时出现异常:org.hibernate.exception.GenericJDBCException

问题描述 hibernate执行保存对象时出现异常:org.hibernate.exception.GenericJDBCException hibernate执行保存对象时出现异常:org.hibernate.exception.GenericJDBCException: could not insert: [com.hibernate.domain.User] Caused by: java.sql.SQLException: Field 'user_id' doesn't have a d

【SSH系列】---Hibernate的基本映射

       开篇前言       在前面的博文中,小编分别介绍了[SSH系列]-- hibernate基本原理&&入门demo,通过这篇博文,小伙伴们对hibernate已经有了基本的了解,以及hibernate的核心,采用对象化的思维操作关系型数据库.     [SSH系列]-- Hibernate持久化对象的三种状态 ,通过这篇博文的讲解,小伙伴们了解到java对象的生命周期,是从通过new语句创建开始,到不再被任何引用变量引用结束,结束后它占用的内存将被JVM垃圾回收机制收回.在h

【SSH系列】-- Hibernate持久化对象的三种状态

       在上一篇博文中,小编主要简单的介绍了[SSH系列]--hibernate基本原理&&入门demo,今天小编来继续介绍hibernate的相关知识, 大家知道,Java对象的生命周期,是从通过new语句创建开始,到不再被任何引用变量引用结束,结束后它占用的内存将被JVM垃圾回收机制收回.在hibernate中持久化类的对象可以划分为三种状态,分别是瞬态,持久态,脱管态.       一.瞬态(Transient),也叫临时态.处于这种状态的对象具备的特征如下:       a.

ssh开发步骤

问题描述 哪位高人能说明一下,ssh开发的具体步骤吗? 解决方案 解决方案二:很详细.解决方案三:该回复于2011-04-16 11:15:15被版主删除解决方案四:非常感谢!!另外问一下,你们开发时先创建数据库表然后再反向工程自动生成pojo类:还是先写实体类在生成数据库表哪个更规范更简单一些呀!求高人指点!解决方案五:先加hibernate和spring,创建好实体类和数据访问类,单元测试没问题后,在集成struts.

ssh开发中,如何把表中的一个字段的值相同的记录统计数量,并在jsp页面显示?

问题描述 ssh开发中,如何把表中的一个字段的值相同的记录统计数量,并在jsp页面显示? 解决方案 用group分组后统计,sql:select 字段名称 count(*) AS 记录数 from A group by 字段名称; 解决方案二: sql语句 : select sum(case 字段名 when 特定值 then 1 else 0 end) from 表名:希望可以帮到你! 解决方案三: select count(*) from 表 where 字段 =?然后在和其它查询结合在一起

sql query-J2EE SSH框架中 hibernate映射文件hbm.xml相关问题

问题描述 J2EE SSH框架中 hibernate映射文件hbm.xml相关问题 使用hbm.xml文件时,有遇到一个标签,在标签中我只要HQL语句加上小于<号MyEclipse就提示错误,那我该如何添加小于号呢,请问大家是怎么回事,如何解决? 具体如下图 解决方案 需要转义的. < > 分别表示 < 和 >! 如果还有其他的,可以查看CSDN移动问答 解决方案二: 打开方式的问题 在MyEclipse的资源树里右击该文件,"Open as"选择合适的方