ych

2007年8月29日

通过exp导出与imp导入进行数据的备份转移:
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(与某一数据库对应的oracle服务名)数据库进行整体导出
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表示如果被导入的数据库中某个表已经存在就忽略不导入那个表
3表示只导入grid1这个表

在导入导出前要先测试下对应的数据库是否是通的:tnsping test来测试,同样test是服务名
所有命令可在cmd下执行
posted @ 2008-09-03 11:57 changhong 阅读(91) | 评论 (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
        {
            /*
             * 取当前系统路径
             */
            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 阅读(188) | 评论 (0)编辑 收藏

导航

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

统计

常用链接

留言簿(1)

随笔档案

文章档案

相册

搜索

最新评论

阅读排行榜

评论排行榜