请问sql批处理时怎么才能查出是哪条sql执行不成功
- try{
- stmt=conn.createStatement();
- conn.setAutoCommit(false);//取消自动提交
- stmt.addBatch("insert into person (name,password,age)values('A','AAA',20)");
- stmt.addBatch("insert into person (name,password,age)values('B','BBB',20)");
- stmt.addBatch("insert into person (name,password,age)values('C','CCC',24)");
- stmt.addBatch("insert into person (name,password,age)values('D','DDD',46)");
- stmt.addBatch("insert into person (name,password,age)values('E','EEE',20)");
- //执行批处理语句
- stmt.excuteBatch();
- //如果没有异常,则执行此段代码
- //提交事务,真正向数据库中提交数据
- conn.commit();
- }catch(Exception e){
- //将数据回滚
- try{
- conn.rollback();
- }catch(Exception e1){
-
- }
- }finally{
- //关闭
- }