| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 787 人关注过本帖
标题:用Hibernate连接MySQL的异常。。
只看楼主 加入收藏
haizhen448
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-7-23
收藏
 问题点数:0 回复次数:1 
用Hibernate连接MySQL的异常。。
原来是连Oracle的,昨天改成MySQL,重新建的表,不知道哪出错了。。
真诚请教。。
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Hibernate: insert into huanghz (reason, amount, bank, type, pid) values (?, ?, ?, '卡', ?)
Exception in thread "main" org.hibernate.exception.DataException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:91)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:86)
at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:171)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2048)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2427)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at huanghz.biz.test.OneTablePerclass.main(OneTablePerclass.java:18)
Caused by: java.sql.BatchUpdateException: Out of range value adjusted for column 'pid' at row 1
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1566)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
搜索更多相关主题的帖子: Hibernate MySQL 
2007-05-17 22:28
haizhen448
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-7-23
收藏
得分:0 

package huanghz.biz.test;
import org.hibernate.Session;
import org.hibernate.Transaction;

import huanghz.biz.entity.CarPayment;
import huanghz.biz.entity.CashPayment;
import huanghz.biz.entity.Payment;
import Util.HbnUtil;
public class OneTablePerclass {
public static void main(String[] args) {
Payment car=new CarPayment("吹黑哨被罚",10000,"中国农业银行");
Payment cash=new CashPayment("把钱扔地上了",100,"日元");

Session s=HbnUtil.getSession();
Transaction tran=s.beginTransaction();//at huanghz.biz.test.OneTablePerclass.main(OneTablePerclass.java:18)
s.save(car);
s.save(cash);
tran.commit();
s.close();
}
}

[此贴子已经被作者于2007-5-17 22:31:37编辑过]

2007-05-17 22:30
快速回复:用Hibernate连接MySQL的异常。。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016575 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved