home.create(categoryId,category,categoryDescription);
放到
CategoryESMHome home=(CategoryESMHome)context.lookup("CategoryESMHome");
语句前看看
放到
CategoryESMHome home=(CategoryESMHome)context.lookup("CategoryESMHome");
语句前看看
解决方案 »
- hibernate 左外连接通过配置文件是怎么配的?
- SSH中如何按照姓名去查找数据库,并显示到页面上来
- hibernate+DAO+STRUTS无法更新
- 登陆后返回原来访问的页面
- 探索IT人士关注的书刊杂志与博客
- hibernate 怎么实现嵌套子查询 ?
- struts2 ognl问题
- google checkout 紧急求助
- 有看过j2ee tutorial 1.3中文版的高手么帮个忙,我按书里说明打包j2ee应用程序客户端,生成的jar文件老是加不进ConverterApp.ear文件中?
- 求助,用SNMP获得MAC物理地址的方法
- 客户端程序不在JBuilder环境下该怎么调用会话bean?我已在JBuilder下成功部署EJB到WebLogic7,而且客户端程序在JBuilder下可以运行,如脱
- eclipse2.1.2+Lomboz2.1.1+tomcat4.1.30的配置问题?
String categoryDescription)throws Exception {
CategoryESMHome home=(CategoryESMHome)context.lookup("CategoryESMHome");
try{
CategoryESM categoryESM=home.findByPrimaryKey(categoryId);
}catch(Exception ex){
home.create(categoryId,category,categoryDescription);
} }
上面那位兄弟,这样为什么不行啊?它应该出现什么异常,怎么捕捉这个异常呢?谢谢你
home.create(categoryId,category,categoryDescription);
}
是不是应该改为
catch(FindException ex){
try{
home.create(categoryId,category,categoryDescription);
}
catch(Exception e){
}
}因为,如果是因其它异常产生的Exception如果被catch住的话,由于已经存在一个categoryId
你再新建一个categoryId,这样主键会产生冲突。:)
再者create语句也会产生Exception的啊。