`
gstarwd
  • 浏览: 1511907 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Could not execute JDBC batch update(hibernate 错误解决)

阅读更多

用的什么数据库 可能是你用的数据库不支持批处理?

我用的是Mysql

 

 

 

 

 

1.       错误: java.lang.NullPointerException

原因: 发现 dao 实例、 manage 实例等需要注入的东西没有被注入

解决:这个时候,你应该查看日志文件;默认是应用服务器的 log 文件,比如 Tomcat 就是 [Tomcat 安装目录 ]/logs ;你会发现提示你:

可能是: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sf' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.HibernateException: could not configure from URL: file:src/hibernate.cfg.xml

org.hibernate.HibernateException: could not configure from URL: file:src/hibernate.cfg.xml

………………………. Caused by: java.io.FileNotFoundException: src\hibernate.cfg.xml

可能是: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: Resource: com/mcc/coupon/model/UserRole.hbm.xml not found

org.hibernate.MappingException: Resource: com/mcc/coupon/model/UserRole.hbm.xml not found

然后你就知道原因是因为配置文件的解析出了错误,这个通过 Web 页面是看不出来的。

更多的是持久化影射文件出的错误;导致了没有被解析;当然你需要的功能就无法使用了。

2.       错误:

StandardWrapperValve[action]: Servlet.service() for servlet action threw exception
javax.servlet.jsp.JspException: Cannot retrieve mapping for action /settlementTypeManage

或者:

     type Status report

     message Servlet action is not available

     description The requested resource (Servlet action is not available) is not available.
原因:
1

3.       错误

StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception

java.lang.ClassNotFoundException: org.apache.struts.taglib.bean.CookieTei

界面错误具体描述:
org.apache.jasper.JasperException: Failed to load or instantiate TagExtraInfo class: org.apache
.struts.taglib.bean.CookieTei
原因与解决:


<


方案一


>


你的“


html:


”开头的标签没有放在一个


<html:form>


中;


<


方案





>


重新启动你的应用服务器,自动就没有这个问题了


4.      








错误:


Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could no
t execute JDBC batch update


原因与解决:


因为


Hibernate Tools


(或者


Eclipse


本身的


Database Explorer


)生成


*.hbn.xml


工具中包含有


catalog="***"





*表示数据库









名称)这样的属性,将该属性删除就可以了



5.      








错误:


org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations)

 

原因与 解决:
方法 1 删除 Set 方的 cascade
方法 2 解决关联关系后,再删除
方法 3 many-to-one 方增加 cascade 但值不能是 none
最后一招:
检查一下
hashCode equals 是否使用了 id 作为唯一标示的选项了;我用 uuid.hex 时是没有问题的;

但是用了 native ,就不行了,怎么办?删除啊! 这个错误可以参见:
http://www.blogjava.net/crazycy/archive/2006/06/24/54939.html

6.       错误:

exception javax.servlet.ServletException: BeanUtils.populat

root cause

java.lang.IllegalArgumentException:Cannot invoke ***Form.set*** - argument type mismatch

原因

问题发生在如下两种情况:

*          Form 中是 Date 类型

*          上传文件时

一般Form 中都是用 java.util.Date ,界面使用 <html:text property=”date”/>; 都是没有问题的。

所以第一次遇到这个错误时,捣鼓了一个下午。

解决:

第一个问题:你把 Date 换成 String ;在 Action 中进行转换;当然转换要借助于 SimpleDateFormat

e 方法喽

第二个问题:记得在 form 中增加 enctype="multipart/form-data" 呵呵

 

7.       问题: 今天用 Tomcat5.5.12 ,发现原来很好用的系统不能用了,反复测试发现页面中不能包含 taglib ,否则会出现以下提示:

HTTP Status 500 -type Exception report

Message

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

exception

org.apache.jasper.JasperException: /index.jsp(1,1) Unable to read TLD "META-INF/tlds/struts-bean.tld" from JAR file "file:*****/WEB-INF/lib/struts.jar":

原因: 更新了工程用的 lib 文件夹下的 jar ,发布时也发布了 servlet.jar jsp-api.jar

解决: jsp-api.jar 删除就解决这个问题了。

8.       问题: Tomcat5.0.20 中差错可以通过 [Tomcat 安装目录 ]/logs 下的 localhost_log.2006-07-14.txt 类似的文件看具体的错误日志,但是在 5.5 中就找不到了

原因与解决: [Tomcat 安装目录 ]/bin 下的 tomcat5w.exe logging 标签捣鼓了一会,然后重起就有了。

原因具体说不准,用非安装版也有这个问题。

最终解决方案:
   http://tomcat.apache.org/tomcat-5.5-doc/logging.html

分享到:
评论

相关推荐

    could not execute

    could not execute:bad executable format(win32 error 193) 下了一个实现MD5的代码,编译时没有错误,但是执行的时候却提示:could not execute:bad executable format(win32 error 193)

    Hibernate错误及解决办法集合

    ### Hibernate常见错误及解决办法 #### 一、Nodefaultconstructorforentity 错误 **问题描述**:在使用Hibernate执行查询语句时,系统抛出`Nodefaultconstructorforentity`错误。 **可能原因**:该错误通常是由于...

    MyEclipse注册机

    Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update 或者org.springframework.jdbc.BadSqlGrammarException: Hibernate operation: could not insert: ...

    Hibernate映射导致的几个异常

    SQLGrammerException, Could not execute JDBC batch update 当执行批量更新操作时,如果SQL语法错误或数据库不支持批处理,可能会遇到此异常。检查SQL语句的语法正确性,以及数据库驱动是否支持所需的批处理功能...

    关键字user附近有语法错误解决方案

    警告: SQL Error: 156, ...org.hibernate.exception.SQLGrammarException: could not execute query org.hibernate.util.JDBCExceptionReporter logExceptions 严重: 关键字 'user' 附近有语法错误。 的解决方案。

    hibernate 排错 宝典1

    ### 错误四:`org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update` **错误现象**: 在执行数据库批量操作时,Hibernate抛出`SQLGrammarException`,表明SQL语法错误或数据库不支持...

    windump3.9.3+winpcap

    Windump和WinPcap是网络数据包捕获和分析的两个...通过熟练掌握这两个工具的使用,可以极大地提升工作效率,解决复杂网络问题。在处理网络故障、进行安全审计或监控网络行为时,Windump和WinPcap都是不可或缺的工具。

    制作调试过程及数据记录1

    另一个常见的问题是在级联操作时,如级联删除,可能会遇到`Hibernate: Could not execute JDBC batch update`的错误。这通常是由于Hibernate在执行数据库更新操作时出现了问题。为了解决这个问题,我们需要在实体类...

    遇到的问题1

    8. **JDBC批量更新失败**: "Could not execute JDBC batch update"可能是因为试图删除与外键关联的数据,检查数据库约束并处理好关联关系。 9. **懒加载问题**: "Stream close"提示没有启用懒加载,需要在Hibernate...

    MyEclipse报错说明

    3. **Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update** Hibernate在执行数据库批处理更新时出现SQL语法错误,可能是由于数据库表不存在或结构不符...

    精心整理的ssh2 一些错误问题的记录(推荐)

    ### 错误三:Could not execute JDBC batch update; nested exception is org.hibernate.exception.ConstraintViolationException 此错误表示在执行批量更新操作时违反了数据库约束,可能是外键约束、唯一性约束等...

    maven出现:Failed to execute goal on project …: Could not resolve dependencies for project …

    在使用Maven构建Java项目时,可能会遇到这样一个错误:“Failed to execute goal on project …: Could not resolve dependencies for project …”。这个错误通常表明Maven在构建过程中遇到了依赖解析问题,无法...

    JDBC中PreparedStatement接口提供的execute、executeQuery和executeUpdate之间的区别及用法

    JDBC 中 PreparedStatement 接口提供的 execute、executeQuery 和 executeUpdate 之间的区别及用法 JDBC 中的 PreparedStatement 接口提供了三种执行 SQL 语句的方法:executeQuery、executeUpdate 和 execute。...

    EXECUTE

    在IT行业中,"EXECUTE"通常与编程和脚本执行紧密相关。这可能是指在某个程序、脚本或操作系统命令中触发执行的动作。当我们谈论"EXECUTE"时,我们主要关注的是代码的运行过程,这涉及到计算机语言的理解、编译(如果...

    框架集合错误解决方案

    nested exception is org.hibernate.exception.SQLGrammarException: could not execute query ``` **问题描述:** 这通常是因为Hibernate执行SQL查询时遇到了语法错误或者数据表结构不匹配等问题。 **解决方法:...

    SSH整合项目中容易出现的错误

    nested exception is org.hibernate.exception.SQLGrammarException: could not execute query 这个错误是由于SQL语句有错误,导致查询失败。解决方法是检查SQL语句的正确性,确保语句正确无误。 4. 严重: Error ...

    SpringJDBC.rar_SpringJDBC_spring jdbc

    - 对于批量插入或更新,Spring JDBC提供了`batchUpdate()`方法,可以有效地提高性能。 5. **异常处理**: - Spring JDBC将JDBC的异常转换为Spring的`DataAccessException`家族,使得异常处理更加统一和简单。 6....

    JDBCJDBC高级应用

    4. **批处理更新(Batch Update)**: - 批处理可以提高数据库操作的性能,避免频繁的网络通信。通过 `Statement` 对象的 `addBatch(String sql)` 方法添加SQL语句到批处理队列,然后通过 `executeBatch()` 执行...

    Spring JDBC相关jar包:spring_jdbc_4.0.0.zip

    4. **批量操作**:对于需要多次执行相同SQL的情况,`JdbcTemplate`的`batchUpdate`方法可以有效地进行批量处理,提高性能。 5. **事务管理**:Spring JDBC模块与Spring的事务管理相集成,可以方便地进行编程式或...

Global site tag (gtag.js) - Google Analytics