????1???????JDBC????ORACLE???????DELETE??????????JAVA?????????? ORACLE?????????????????′????????磬?????ο???
?????? Oracle??????????????????100?????????????????????????????????????
?????????????????£?Oracle?н????Щ????????
????(1)???????auto-commit?????????????????????oracle??????????commit??commit??????????????????????????????????1000??????????commit. ???????????????
????(2)???????batch update?????????batch?????delete???????????????????oracle??1?????????????1??δ?????????100??????????????????Oracle??С?????????100?ο??????????????????????????????
??????????Щ???飬????????Oracle?ο???鵽??
????2?????oracle???????????commit??????浽??????????′????????磬?????ο???
??????????????Commit??Rollback ???????DML(???????????) - Insert??Update??Delete ??Щ?????????????????????????????????????rollback??????commit?????????????????????????????????exit????????????????????commit?????????????????????????????commit??
????3?????jdbc ?????????????? ?100??????Σ??????????ν????????′????????磬?????ο???
??????
????String sql="insert into t1(id) values (?)";
????Connection con=null;
????PreparedStatement ps=null;
????con= dao.getConnection();
????ps=con.prepareStatement(sql);
????ps.addBatch();
??????
????if(i%100==0)//?100???????
????{
????ps.executeBatch();
????con.commit();
????ps.clearBatch();
????}
???????
????if(i%100==0||i==(list.size()-1)){
????ps.executeBatch();
????con.commit();
????ps.clearBatch();
????}
????4???????????????????????磬?????ο???
??????1???????????conn.setAutoCommit(false)?????????????????????????????????????????
??????2????pstmt.executeBatch(); //PreparedStatementpstmt
????conn.commit();
???????????????????????
??????3??????????????????x???磺??????????????
??????4????????“???????.????”?????????????????
??????????????дJdbcUtil??DB_CONNECTION = "jdbc:mysql://localhost:3306/"???
??????????嵽?????????????????????????
??????5????Statement??PrepareStatement???????????DDL?????????????????sql?????????????execute(String sql)??????
????5??conn.setAutoCommit(true)??(false)???????????????磬?????ο???
????JDBC?е????????
????true??sql?????????commit??????????????
????false??sql???????????ó???????????????commit????rollback????
???????jdbc?????????в????????conn.commit()?????????????????????????????????????autocommit?????false?????????????β???????????????commit??
????6???????????????????????дconn.commit()???????
??????????????????????conn?????μ???
????conn.setAutoCommit(true)???????????SQL?????????????
????7???????
????1.java??????????10000??sql?????commit???????13.395s??sql*plus???????????????sql*plus
??????????????????
????2.??sql*plus???????????????? delete from "TAB_orderDetail"?????commit??;????????ε?
????sql*plus?в??????????0??????java??????????б?????????????????????sql*plus?????????
?????10000????????????sql*plus????????????????????commit?????
????3.??java???????????????? delete from "TAB_orderDetail"?????commit??????java??????????0
????????sql*plus?в???????0.????????????????????
??????????
????1??java??????????10000??????sql?????commit???????7.652s??java??????????10000??sql???
??????commit???????7.595s?????????????????????100000??????????52.867s???????????10000??????????5.337s??