当前位置: 代码迷 >> J2EE >> org.springframework.dao.InvalidDataAccessResourceUsageException: Could not execute JDBC batch update
  详细解决方案

org.springframework.dao.InvalidDataAccessResourceUsageException: Could not execute JDBC batch update

热度:507   发布时间:2016-04-22 02:18:41.0
关于ssh往mysql里面注入数据的问题
小弟在写网上商城,数据库里面有个商品的状态的字段,1为该商品存在,0为该商品不存在,当我在网页上面点击删除的时候,会根据该商品的ID找到对应的商品并将该商品设置为0,具体代码如下:
productServiceImpl文件:
@Override
public String delete(Product product) {
product = productDao.findById(product.getId());
product.setState(0);
productDao.delete(product);
return null;
}
productDaoImpl文件:
@Override
public String delete(Product product) {
hibernateTemplate.update(product);
return "success";
}
但是在我的mysql数据库中,该表还有一个上架及下架时间,我在网上查了的,说是java。sql。date对应数据库中的date,java。sql。timestamp对应数据库中的datetime,但是我在数据库分别按这两个设置好后,eclipse里面没有报异常,但是网页上显示错误如下:(就是这两个时间引起的,因为我删除这连个字段就好了,但是我现在不知道怎么来处理这个了,)
HTTP Status 500 - 
type Exception report

message 

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

exception 

org.springframework.dao.InvalidDataAccessResourceUsageException: Could not execute JDBC batch update; SQL [update product set allNumber=?, author=?, bookConcern=?, detail=?, downDate=?, format=?, isbn=?, name=?, number=?, packageMessage=?, page=?, paper=?, photoPath=?, price=?, printDate=?, printNumber=?, productType_id=?, publishDate=?, remainNumber=?, state=?, upDate=?, version=?, wordage=? where id=?]; nested exception is org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:633)
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.update(HibernateTemplate.java:705)
org.springframework.orm.hibernate3.HibernateTemplate.update(HibernateTemplate.java:701)
com.yeliguo.back.dao.impl.ProductDaoImpl.delete(ProductDaoImpl.java:36)
com.yeliguo.back.service.impl.ProductServiceImpl.delete(ProductServiceImpl.java:41)
com.yeliguo.back.action.ProductAction.delete(ProductAction.java:40)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
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)
  相关解决方案