1.Use jdbc connect to mysql,dump the data
2.Use POI or odbc fill the data to access
3.Use GZIPOUTPUTSTREAM to tar a zip(Not sure,I forget)

解决方案 »

  1.   

    先将sql数据倒到access里(两个连接),然后将access库压缩,压缩的方法java里又专门的包。
      

  2.   

    我需要解决的是:
    比如说一个客户要查看当天有没有新的数据更新,他提交一个请求,在WEB服务器端响应该客户的请求,查询数据库服务器当天有没有新的记录产生,如果有新数据记录的话,取出当天记录集,并以access数据库的格式保存(.mdb)当天的数据记录,存放在数据库服务器的某个路径下文件名称可以当天的日期为名称。然后对该access数据库文件(.mdb)进行ZIP压缩,生成的.ZIP压缩包存放在数据库服务器的另一个路径下面,让后把WEB服务器断获取该.ZIP压缩包的路径并发给客户端,提供其下载。
      现在的问题是如何把用java写一段代码实现把mssql记录集存为ACCESS数据库格式的文件!!!
      

  3.   

    感觉其他的并不复杂,只是不知道怎么才能把记录集保存成一个mdb的格式,而且是可用的。读取数据库,压缩都是java基本的功能,用servlet很好实现。--------------------------
    让生命时刻充满着激情!
      

  4.   

    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    public class ZipCompress {  /**
       * 对文件进行压缩操作
       * @param strSourceFilePath 压缩文件的原文件路径
       * @param strSourceFile 压缩文件的原文件的文件名
       * @param strZipPath 压缩处理后的文件存放路径
       * @param strZipFile 压缩处理后的文件名
       * @return 压缩是否成功
       */
      public static boolean zipFile(String strSourceFilePath,String strSourceFile,String strZipPath,String strZipFile){
        try {
          FileOutputStream f = new FileOutputStream(strZipPath+strZipFile+".zip");
          ZipOutputStream out = new ZipOutputStream(new DataOutputStream(f));
    // for(int i = 0; i < args.length; i++) {
          System.out.println(  "reading file " + strSourceFilePath+strSourceFile);
          DataInputStream in =new DataInputStream(new FileInputStream(strSourceFilePath+strSourceFile));
          out.putNextEntry(new ZipEntry(strSourceFile));
          int c;
          while((c = in.read()) != -1){
            out.write(c);
          }
          in.close();
    // }
          out.close();
          return true;
        } catch(Exception e) {
          e.printStackTrace();
        }
        return false;
      }  /**
       * 对数据流进行压缩处理
       * @param source 要进行压缩处理的数据流
       * @param strFileName 压缩文件的相对路径
       * @param strZipPath 压缩处理后的文件路径
       * @param strZipFile 压缩处理后的文件名
       * @return 压缩处理是否成功
       */
      public static boolean zip(byte[] source,String strFileName,String strZipPath,String strZipFile){
        try {
          FileOutputStream f = new FileOutputStream(strZipPath+strZipFile+".zip");
          ZipOutputStream out = new ZipOutputStream(new DataOutputStream(f));
    // for(int i = 0; i < args.length; i++) {
    // System.out.println(  "reading data " + source);
    // DataInputStream in =new DataInputStream(new FileInputStream(strSourceFilePath+strSourceFile));
          out.putNextEntry(new ZipEntry(strFileName));
    // int c;
    // while((c = in.read()) != -1){
          out.write(source);
    // }
    // in.close();
    // }
          out.close();
          return true;
        } catch(Exception e) {
          e.printStackTrace();
        }
        return false;
      }  /**
       * 对文件进行解压缩处理
       * @param strZipPath 解压缩的文件路径
       * @param strZipFile 解压缩的文件名
       * @param strSourceFilePath 解压缩处理后的文件存放路径
       * @param strSourceFile 解压缩处理后的文件名
       * @return 解压缩是否成功
       */
      public static boolean unizipFile(String strZipPath,String strZipFile,String strSourceFilePath,String strSourceFile){
        try {
          FileInputStream f = new FileInputStream(strZipPath+strZipFile+".zip");
          ZipInputStream in = new ZipInputStream(new DataInputStream(f));
    // for(int i = 0; i < args.length; i++) {
          System.out.println(  "Writing file " + strSourceFilePath+strSourceFile);
          DataOutputStream out =new DataOutputStream(new FileOutputStream(strSourceFilePath+strSourceFile));
          in.getNextEntry();
          int c;
          while((c = in.read()) != -1){
            out.write(c);
          }
          in.close();
    // }
          out.close();
          return true;
        } catch(Exception e) {
          e.printStackTrace();
        }
        return false;
      }  /**
       * 对压缩文件进行解压缩处理
       * @param strZipPath 压缩文件存放路径
       * @param strZipFile 压缩文件的文件名
       * @return 返回解压缩处理后的文件流
       */
      public static byte[] unizip(String strZipPath,String strZipFile){
    // StringBuffer buf=new StringBuffer(10000);
        byte[] buffer=null;
        try {
          FileInputStream f = new FileInputStream(strZipPath+strZipFile+".zip");
          ZipInputStream in = new ZipInputStream(new DataInputStream(f));
          System.out.println(  "reading file " + strZipPath+strZipFile+".zip");
          ZipEntry d=in.getNextEntry();// buffer=new byte[(int)d.getSize()];      int c;
    // c=in.read(buffer);
          byte[] by=new byte[1000];
          String str;
          while((c=in.read(by)) != -1){
            buffer=appendbytes(buffer,by,c);
          }
          in.close();    } catch(Exception e) {
          e.printStackTrace();
        }
        return buffer;
      }
      public static void main(String[] args) {
        ZipCompress a=new ZipCompress();
        try{
          a.zip("你好".getBytes(),"aa.txt","d:/","aa");
        }catch(Exception e){
          e.printStackTrace();
        }
        byte[] temp=a.unizip("d:/","huangzg");
        System.out.println(new String(temp));
      }  /**
       * 对字节的追加操作
       * @param a 原字节
       * @param b 添加的字节
       * @param length 添加字节的长度
       * @return 添加字节处理后的字节
       */
      private static byte[] appendbytes(byte[] a,byte[] b,int length){
        int lengtha=0;
        if(a!=null){
          lengtha=a.length;
        }
        if(b==null||length<1){
          return a;
        }
        byte[] c=new byte[lengtha+length];
        for(int i=0;i<lengtha;i++){
          c[i]=a[i];
        }
        for(int j=0;j<length;j++){
          c[j+lengtha]=b[j];
        }
        return c;
      }
    } /**
       * 进行压缩文件的处理
       * @param source
       * @return
       */
      private boolean zipFile(byte[] source){
        boolean success=false;
        try{
          success= ZipCompress.zip(source,_fileName.concat(".xml"),_filePath,_fileName);
        }catch(Exception ex){
          errMsg = "压缩文件的过程失败!";
          ExcAct.doHandle(ex);
        }
        return success;
      }调用的时候像这样 /**
       * 进行压缩文件的处理
       * @param source
       * @return
       */
      private boolean zipFile(byte[] source){
        boolean success=false;
        try{
          success= ZipCompress.zip(source,_fileName.concat(".xml"),_filePath,_fileName);
        }catch(Exception ex){
          errMsg = "压缩文件的过程失败!";
        }
        return success;
      }
      

  5.   

    现在的问题是如何把用java写一段代码实现把mssql记录集存为ACCESS数据库格式的文件!!!办法一:在数据库服务器新建一个空.mdb文件,判断出如果SMSQL数据库有新数据,把.mdb文件另存为“当前日期.mdb”文件,放在数据库服务器的一个指定文件夹中,然后用select “MSSQL数据库字段名” into “.mdb文件中”  from “MSSQL数据库表名” where “判断条件”   请问高手门 能否同时在一条SQL语句中连接2个不同的数据库啊!!!  有什么方法没
      

  6.   

    哪位精通MSSQL和JAVA的高手指点一下 怎么实现该功能
      

  7.   

    想到一个办法,分享一下 ,大家看一下是否可行
    数据库服务器端每30分钟 查询一次 是否存在当天数据记录 如果存在 就导出数据到.mdb文件中 并以当天日期为名保存  客户端提交一个下载更新请求到WEB服务器端,WEB服务器端同过filter类来判断其合法性后 在数据库服务器存放.mdb文件的文件夹中查询 是否存在有以当天日期为名的.mdb文件 如果有 则把他打成.zip包 并保存在服务器端的某个路径下,在将其路径发送给客户端 ,让其下载