executeBatch 如何得到是哪些语句出错

  1.     Connection conn = null;   
  2.     PreparedStatement pst = null;   
  3.     ResultSet rs = null;   
  4.     int[] arr = null;   
  5.     int[] arrEx = null;   
  6.     boolean success = true;   
  7.     try {   
  8.   
  9.       Class.forName("oracle.jdbc.driver.OracleDriver");;   
  10.       conn = DriverManager.getConnection(   
  11.           "jdbc:oracle:thin:@localhost:1521:ora92""test""test");;   
  12.       DatabaseMetaData dbmd = conn.getMetaData();;   
  13.       System.out.println(dbmd.supportsBatchUpdates(););;   
  14.       System.out.println(conn.getAutoCommit(););;   
  15. //      conn.setAutoCommit(false);;   
  16.       pst = conn.prepareStatement("insert into temp values(?);");;   
  17.       int temp = 0;   
  18.       for (int i = 90; i < 120; i++); {   
  19.         temp = i;   
  20.         if (temp > 110); {   
  21.           temp -= 100;   
  22.         }   
  23.         pst.setInt(1, temp);;   
  24.         pst.addBatch();;   
  25.       }   
  26.       arr = pst.executeBatch();;   
  27.     }   
  28.     catch (ClassNotFoundException e); {   
  29.       System.out.println(e);;   
  30.       success = false;   
  31.     }   
  32.     catch (BatchUpdateException e); {   
  33.       System.out.println(arr == null);;   
  34.       success = false;   
  35.       arrEx = e.getUpdateCounts();;   
  36.       System.out.println(arrEx.length);;   
  37.       for (int i = 0; i < arrEx.length; i++); {   
  38.         System.out.println(arrEx[i]);;   
  39.       }   
  40.   
  41.       System.out.println(e);;   
  42.     }   
  43.     catch (SQLException e); {   
  44.       success = false;   
  45.       System.out.println(e);;   
  46.     }   
  47.     finally {   
  48.   
  49. //      try {   
  50. //        if(success);{   
  51. //          conn.commit();;   
  52. //        }else{   
  53. //          conn.rollback();;   
  54. //        }   
  55. //      }   
  56. //      catch (SQLException se); {   
  57. //        System.out.println(se);;   
  58. //   
  59. //      }   
  60.       if (rs != null); {   
  61.         try {   
  62.           rs.close();;   
  63.           rs = null;   
  64.         }   
  65.         catch (Exception e); {}   
  66.       }   
  67.       if (pst != null); {   
  68.         try {   
  69.           pst.close();;   
  70.           pst = null;   
  71.         }   
  72.         catch (Exception e); {}   
  73.       }   
  74.       if (conn != null); {   
  75.         try {   
  76.           conn.close();;   
  77.           conn = null;   
  78.         }   
  79.         catch (Exception e); {}   
  80.       }   
  81.     }  

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值