概述
- Connection conn = null;
- PreparedStatement pst = null;
- ResultSet rs = null;
- int[] arr = null;
- int[] arrEx = null;
- boolean success = true;
- try {
- Class.forName("oracle.jdbc.driver.OracleDriver");;
- conn = DriverManager.getConnection(
- "jdbc:oracle:thin:@localhost:1521:ora92", "test", "test");;
- DatabaseMetaData dbmd = conn.getMetaData();;
- System.out.println(dbmd.supportsBatchUpdates(););;
- System.out.println(conn.getAutoCommit(););;
- // conn.setAutoCommit(false);;
- pst = conn.prepareStatement("insert into temp values(?);");;
- int temp = 0;
- for (int i = 90; i < 120; i++); {
- temp = i;
- if (temp > 110); {
- temp -= 100;
- }
- pst.setInt(1, temp);;
- pst.addBatch();;
- }
- arr = pst.executeBatch();;
- }
- catch (ClassNotFoundException e); {
- System.out.println(e);;
- success = false;
- }
- catch (BatchUpdateException e); {
- System.out.println(arr == null);;
- success = false;
- arrEx = e.getUpdateCounts();;
- System.out.println(arrEx.length);;
- for (int i = 0; i < arrEx.length; i++); {
- System.out.println(arrEx[i]);;
- }
- System.out.println(e);;
- }
- catch (SQLException e); {
- success = false;
- System.out.println(e);;
- }
- finally {
- // try {
- // if(success);{
- // conn.commit();;
- // }else{
- // conn.rollback();;
- // }
- // }
- // catch (SQLException se); {
- // System.out.println(se);;
- //
- // }
- if (rs != null); {
- try {
- rs.close();;
- rs = null;
- }
- catch (Exception e); {}
- }
- if (pst != null); {
- try {
- pst.close();;
- pst = null;
- }
- catch (Exception e); {}
- }
- if (conn != null); {
- try {
- conn.close();;
- conn = null;
- }
- catch (Exception e); {}
- }
- }
最后
以上就是感动毛豆为你收集整理的executeBatch 如何得到是哪些语句出错的全部内容,希望文章能够帮你解决executeBatch 如何得到是哪些语句出错所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复