- 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); {}
- }
- }