ych

          2007年8月29日

          通過exp導出與imp導入進行數(shù)據(jù)的備份轉移:
          exp命令:
          1 exp username/psw@TEST file=d:test.dmp full=y
          2 exp username/psw@TEST file=d:test.dmp owner=(ly)
          3 exp username/psw@TEST file= d:test.dmp tables=(grid1,grid2)
          1其中一是將Test(與某一數(shù)據(jù)庫對應的oracle服務名)數(shù)據(jù)庫進行整體導出
          2將屬于用戶ly的所有表導出
          3將表grid1,與grid2導出
          d:test.dmp是導出的文件地址

          imp命令:
          1 imp system/psw@TEST  file=d:test.dmp
          2 imp system/psw@TEST  full=y  file=d:test.dmp ignore=y
          3 imp system/psw@TEST  file=d:test.dmp  tables=(grid1)
          ignore=y表示如果被導入的數(shù)據(jù)庫中某個表已經存在就忽略不導入那個表
          3表示只導入grid1這個表

          在導入導出前要先測試下對應的數(shù)據(jù)庫是否是通的:tnsping test來測試,同樣test是服務名
          所有命令可在cmd下執(zhí)行
          posted @ 2008-09-03 11:57 changhong 閱讀(97) | 評論 (0)編輯 收藏

          http://blog.csdn.net/techyang/archive/2005/08/09/448677.aspx(luanfengxia/arc/2006/05/20/746951.aspx)

           public ActionForward add(ActionMapping mapping, ActionForm form,
             HttpServletRequest request, HttpServletResponse response) throws Exception {
                  String encoding = request.getCharacterEncoding();
                  if ((encoding != null) && (encoding.equalsIgnoreCase("utf-8")))
                  {
                      response.setContentType("text/html; charset=gb2312");//如果沒有指定編碼,編碼格式為gb2312
                  }
                  NodeForm theForm = (NodeForm) form;
                  String nodename=theForm.getNodename();
                  String note=theForm.getNote();
                  FormFile file = theForm.getTheFile1();//取得上傳的文件
                  FormFile file2=theForm.getTheFile2();
                  FormFile file3=theForm.getTheFile3();
                  Session session=null;
                  String forward="";
                  try
                  {
                      /*
                       * 取當前系統(tǒng)路徑
                       */
                      String filePath = this.getServlet().getServletContext()
                      .getRealPath("/");
                      System.out.println("---------------------------------------"+filePath);
                      if(file.getFileSize()!=0){
                      ByteArrayInputStream stream = (ByteArrayInputStream) file.getInputStream();//把文件讀入
                    
                      //ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    
                      /*
                       * 建立一個上傳文件的輸出流
                       */
                      OutputStream bos = new FileOutputStream(filePath +
                              "UploadFiles\\"+file.getFileName());
                      request.setAttribute("fileName",filePath + "/"
                              + file.getFileName());
                      int bytesRead = 0;
                      byte[] buffer = new byte[8192];
                      while ((bytesRead = stream.read(buffer, 0, 8192)) != -1)
                      {
                          bos.write(buffer, 0, bytesRead);//將文件寫入服務器
                      }          
                      bos.close();
                      stream.close();
                      }if(file2.getFileSize()!=0){
                      ByteArrayInputStream stream2 = (ByteArrayInputStream) file2.getInputStream();
                      OutputStream bos2 =  new FileOutputStream(filePath +
                              "UploadFiles\\"+file2.getFileName());//建立一個上傳文件的輸出流
                      int bytesRead2 = 0;
                      byte[] buffer2 = new byte[8192];
                      while ((bytesRead2 = stream2.read(buffer2, 0, 8192)) != -1)
                      {
                          bos2.write(buffer2, 0, bytesRead2);//將文件寫入服務器
                      }          
                      bos2.close();
                      stream2.close();
                      }if(file3.getFileSize()!=0){
                      ByteArrayInputStream stream3 = (ByteArrayInputStream) file3.getInputStream();//把文件讀入
                  OutputStream bos3 =  new FileOutputStream(filePath +
                          "UploadFiles\\"+file3.getFileName());//建立一個上傳文件的輸出流
                  int bytesRead3 = 0;
                  byte[] buffer3 = new byte[8192];

                  while ((bytesRead3 = stream3.read(buffer3, 0, 8192)) != -1)
                  {
                      bos3.write(buffer3, 0, bytesRead3);//將文件寫入服務器
                  }          
                  bos3.close();
                  stream3.close();
                  }
            Configuration config = new Configuration().configure();
            SessionFactory factory = config.buildSessionFactory();
               session = factory.openSession();
                  Transaction transaction = session.beginTransaction();
                  Node node=new Node();
                  node.setNodeName(nodename);
                  node.setXsdName(file.getFileName());
                  node.setXslName(file2.getFileName());
                  node.setXhtmlName(file3.getFileName());
                  node.setNote(note);
                  session.save(node);
            session.flush();
            session.clear();
            forward="display";
                  transaction.commit();
                  }
                  catch (Exception e)
                  {
                   forward="error";
                      System.err.print(e);
                      e.printStackTrace();
                  }
             
            finally{
             session.close();
             }
                  return mapping.findForward(forward);
           }

          posted @ 2007-08-29 13:35 changhong 閱讀(208) | 評論 (0)編輯 收藏

          導航

          <2007年8月>
          2930311234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          統(tǒng)計

          常用鏈接

          留言簿(1)

          隨筆檔案

          文章檔案

          相冊

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 东平县| 凭祥市| 吉安市| 郎溪县| 平陆县| 平南县| 姜堰市| 商都县| 松滋市| 汝州市| 阿荣旗| 通化市| 祥云县| 嘉祥县| 明光市| 武功县| 益阳市| 崇信县| 宁晋县| 浪卡子县| 天长市| 江油市| 班戈县| 肥西县| 汝南县| 龙门县| 昌平区| 环江| 太仆寺旗| 乌兰县| 高雄市| 三江| 汕头市| 青神县| 玉溪市| 伊川县| 务川| 抚远县| 天水市| 陆川县| 体育|