求救:Exception in thread "main" org.springframework.dao.InvalidDataAccessResourceUsageException: Could not execute JDBC batch u

aimama_1314 2007-06-23 11:23:54
我在做Spring+Hibernate 时遇见了下面的问题,已经错了好几天了,数据库也从新建了,表关系也重新映射了。。。。。求救SOS

log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.springframework.dao.InvalidDataAccessResourceUsageException: Could not execute JDBC batch update; nested exception is org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
Caused by: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:390)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:632)
at com.usernews.dao.impl.UserNewsDaoImpl.addNews(UserNewsDaoImpl.java:27)
at com.usernews.operation.impl.UserNewsServiceImpl.CommitNews(UserNewsServiceImpl.java:71)
at com.usernews.text.Text.textAdd(Text.java:121)
at com.usernews.text.Text.main(Text.java:167)
Caused by: java.sql.BatchUpdateException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from, author, startdate, enddate, iconpath, note, checkflag, newsid) values ('ti' at line 1
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1103)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:853)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 12 more
...全文
2465 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
hepeng_8 2011-06-30
  • 打赏
  • 举报
回复
值怎么解决的啊
「已注销」 2011-04-18
  • 打赏
  • 举报
回复
我也出现了这个问题,怎么解决 啊 请教啊!!!!!!!!!
游_子 2008-10-30
  • 打赏
  • 举报
回复
好了啊
aimama_1314 2007-06-23
  • 打赏
  • 举报
回复
谢谢你啊 问题解决了 我怎么给你分亚·
zhkchi 2007-06-23
  • 打赏
  • 举报
回复
<property name="from" type="java.lang.String">
<column name="from" length="20" />
</property>
-------------------

from是sql关键字,不能叫这个名字
aimama_1314 2007-06-23
  • 打赏
  • 举报
回复
好像表关系中也没有Hibernate的关键字 ~~~~闷··············SOS
aimama_1314 2007-06-23
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.serializ.PwUsernews" table="pw_usernews">
<id name="newsid" type="java.lang.Integer">
<column name="newsid" />
<generator class="increment" />
</id>
<property name="title" type="java.lang.String">
<column name="title" length="60" not-null="true" />
</property>
<property name="briefcont" type="java.lang.String">
<column name="briefcont" length="65535" />
</property>
<property name="detail" type="java.lang.String">
<column name="detail" length="65535" not-null="true" />
</property>
<property name="conttype" type="java.lang.String">
<column name="conttype" length="20" not-null="true" />
</property>
<property name="from" type="java.lang.String">
<column name="from" length="20" />
</property>
<property name="author" type="java.lang.String">
<column name="author" length="20" />
</property>
<property name="startdate" type="java.util.Date">
<column name="startdate" length="10" />
</property>
<property name="enddate" type="java.util.Date">
<column name="enddate" length="10" />
</property>
<property name="iconpath" type="java.lang.String">
<column name="iconpath" length="800" />
</property>
<property name="note" type="java.lang.String">
<column name="note" length="100" />
</property>
<property name="checkflag" type="java.lang.String">
<column name="checkflag" length="20" />
</property>
</class>
</hibernate-mapping>
aimama_1314 2007-06-23
  • 打赏
  • 举报
回复
dao层:添加一条数据的方法
/**
* 添加新闻信息
*/

public void addNews(PwUsernews news) throws Exception {
this.getHibernateTemplate().save(news);
}
service层保存数据的方法:
/**
* 保存新增加的新闻
* @return news 对象
*/
public void CommitNews(PwUsernews news) throws Exception {
userNewsDao.addNews(news);
}


就这么两行代码 就一直错错错!!!
在GOOGLE上搜 排除:
因为Hibernate Tools(或者Eclipse本身的Database Explorer)生成*.hbn.xml工具中包含有catalog="***"(*表示数据库名称)这样的属性,将该属性删除就可以了

的因素 因为那个catalog="***"(* 我一上来就删除了 ····闷··请高手指教

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧