Java學習

          java,spring,structs,hibernate,jsf,ireport,jfreechart,jasperreport,tomcat,jboss -----本博客已經搬家了,新的地址是 http://www.javaly.cn 如果有對文章有任何疑問或者有任何不懂的地方,歡迎到www.javaly.cn (Java樂園)指出,我會盡力幫助解決。一起進步

           

          數據庫 批量操作, 函數執行

           1. 批量 delete 和 save

              public void deleteAllData() {
                  List l=this.getHibernateTemplate().find("from SchedulerSeq");
                  if(l!=null && l.size()>0)
                      this.getHibernateTemplate().deleteAll(l);
                 
              }

              public void saveAll(List<BusBatIn> batinList) {
                  this.getHibernateTemplate().saveOrUpdateAll(batinList);
                 
              }

           執行函數

              public void callSaveBusStatus(Date lastTime) {
                  Connection con=this.getSession().connection();

                  PreparedStatement st = null;

                 
                 
                  try {
                      if(lastTime==null){
                          st = con.prepareStatement("select savet_vehicle_status(?) from Dual ");
                          st.setString(1,BusConstant.VEHICLE_BUS);
                      }else{
                          st = con.prepareStatement("select savet_vehicle_status(?,?) from Dual ");
                          st.setTimestamp(1,java.sql.Timestamp.valueOf(String.valueOf(lastTime)));
                          st.setString(2,BusConstant.VEHICLE_BUS);
                      }
                  
                         
                      st.execute();
                                 
                  } catch (SQLException e) {
                      e.printStackTrace();
                  } finally {

                      try{
                          if(st != null){
                              st.close();
                          }
                      } catch (Exception e) {
                          st = null;
                      }
                      try{
                          if(con != null){
                              con.close();
                          }
                      } catch (Exception e) {
                          con = null;
                      }
                  }
                 
              }
           

          posted on 2008-10-24 17:08 找個美女做老婆 閱讀(270) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          導航

          統計

          公告

          本blog已經搬到新家了, 新家:www.javaly.cn
           http://www.javaly.cn

          常用鏈接

          留言簿(6)

          隨筆檔案

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 广南县| 彭阳县| 长子县| 康乐县| 临武县| 乌兰察布市| 玛纳斯县| 威海市| 德江县| 华蓥市| 凯里市| 岳普湖县| 天台县| 绥滨县| 广河县| 晋宁县| 焦作市| 永丰县| 乌拉特后旗| 民权县| 伊通| 黔西| 桂东县| 藁城市| 蒲江县| 双鸭山市| 拉孜县| 云和县| 封开县| 伊宁县| 绍兴县| 巴中市| 合作市| 南康市| 竹溪县| 洛宁县| 池州市| 北宁市| 滦南县| 宁蒗| 东乡族自治县|