java批量执行多条Sql语句

               

/**
   * 执行多条更新的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();//执行
          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();
        }        
      }    
  }

           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

猜你喜欢

转载自blog.csdn.net/fswhwd/article/details/87784111