code: public static void backup(File storageDir, Connection jdbcConn, Map<String, String> scripts) throws BackupException
     {
        Exception exc = null;
  
        ZipObjectWriter contentWriter = null;
        ZipObjectWriter contentLenWriter = null;
  
        try
        {
           contentWriter =
              new ZipObjectWriter(PrivilegedFileHelper.zipOutputStream(new File(storageDir, CONTENT_ZIP_FILE)));
  
           contentLenWriter =
              new ZipObjectWriter(PrivilegedFileHelper.zipOutputStream(new File(storageDir, CONTENT_LEN_ZIP_FILE)));
  
           for (Entry<String, String> entry : scripts.entrySet())
           {
              dumpTable(jdbcConn, entry.getKey(), entry.getValue(), storageDir, contentWriter, contentLenWriter);
           }
        }
        catch (IOException e)
        {
           exc = e;
           throw new BackupException(e);
        }
        catch (SQLException e)
        {
           exc = e;
           throw new BackupException("SQL Exception: " + JDBCUtils.getFullMessage(e), e);
        }
        finally
        {
           if (jdbcConn != null)
           {
              try
              {
                 jdbcConn.close();
              }
              catch (SQLException e)
              {
                 if (exc != null)
                 {
                    LOG.error("Can't close connection", e);
                    throw new BackupException(exc);
                 }
                 else
                 {
                    throw new BackupException(e);
                 }
              }
           }
  
           try
           {
              if (contentWriter != null)
              {
                 contentWriter.close();
              }
  
              if (contentLenWriter != null)
              {
                 contentLenWriter.close();
              }
           }
           catch (IOException e)
           {
              if (exc != null)
              {
                 LOG.error("Can't close zip", e);
                 throw new BackupException(exc);
              }
              else
              {
                 throw new BackupException(e);
              }
           }
        }
     }
docs: Backup tables.
  
  @param storageDir
  the directory to store data
  @param jdbcConn
  the connection to database
  @param scripts
  map which contains table name and respective SQL query to get data
  @throws BackupException
  if any exception occurred