java批量执行多条Sql语句
/**
?? * 執(zhí)行多條更新的Sql語句
?? */
??public boolean UpdataSql(String sql[]){
????TestConnect.Connect();????
?? ? ?try {
???? ? ? ?sta = TestConnect.connection.createStatement();
???? ? ? ?for(int i=0;i???? ? ??? ?sta.addBatch(sql[i]);???? ? ??? ?
???? ? ??? ?System.out.println("輸出SQL語句:"+sql[i]);?????? ? ??? ? ??
???? ? ? ?}?? ??
???? ? ? ?sta.executeBatch();//執(zhí)行
???? ? ? ?return(true);
?? ? ?}
?? ? ?catch (Exception ex) {
???? ? ? ?System.out.println("Error : " + ex.toString());
???? ? ? ?return(false);
???? ? ?}
?? ? ?finally{
?? ? ???try{
?? ? ?????TestConnect.connection.commit();
?? ? ?????sta.close();
?? ? ?????TestConnect.connection.close();
?? ? ?????
?? ? ???}catch(Exception e){
?? ? ?????e.printStackTrace();
?? ? ???}?? ? ???
?? ? ?}????
??}
總結
以上是生活随笔為你收集整理的java批量执行多条Sql语句的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JEECG移动方案 - 应用系统转换移动
- 下一篇: Oracle 游标使用大全