问题描述
现在我正在使用 Oracle 实用程序 UTL_COMPRESS.LZ_COMPRESS()
来压缩一些数据.但问题是它使用 GZIP 兼容格式压缩东西,不幸的是,它也不兼容 ZIP.因此,Windows XP 本机解压实用程序无法打开它(您知道压缩文件夹的东西).并且用户必须使用一些其他实用程序,例如 7Zip
、Winzip
或 Filzip
等,以便对其进行解压缩.
Right now I am using Oracle utility procedure, UTL_COMPRESS.LZ_COMPRESS()
, to compress some data. But the problem is it compresses the thing using GZIP compatible format, which is not also ZIP compatible unfortunately. Therefore, the Windows XP native decompression utility can not open it (you know that compressed folder thingie). And user have to use some other utility, like 7Zip
, Winzip
, or Filzip
etc., in order to decompress that.
因此,我们最终制定了从 Oracle 检索 GZIP 数据的计划,使用 Java 对其进行解压缩,然后将其压缩回 ZIP(可以通过 Windows 实用程序解压缩的内容).compress-in-gzip -> 听起来很荒谬解压 ->再次压缩压缩
.
So, we end up having a plan of retrieving GZIP data from Oracle, uncompress it using Java, and compress it back to ZIP (something that can be decompressed by Windows utility). It sounds ridiculous to compress-in-gzip -> decompress -> compress-again-in-zip
.
知道我们首先如何将其压缩为所需的格式,以避免所有这些额外的计算吗?
推荐答案
有一个支持 WinZip 格式的 Java 包 java.util.zip
.而在 Oracle 中,我们可以构建 Java 存储过程,这些过程以一种可由本机 PL/SQL 程序调用的形式呈现 Java 类.了解更多.
There is a Java package java.util.zip
which supports the WinZip format. And in Oracle we can build java stored procedures which present Java classes in a form which can be called by native PL/SQL programs. Find out more.
所以您需要做的是写出一个包含未压缩状态数据的文件,然后通过 JSP 将其送入压缩.如果您不想编写自己的实现,请查看 Vadim Loevski 撰写的这篇文章.它包括一个用于压缩 OS 文件的 Java 存储过程.
So what you need to do is write out a file containing the data in its uncompressed state and then feed it through a JSP to zip it. If you don't want to write your own implementation then check out this article by Vadim Loevski. It includes a Java Stored Procedure for zipping OS files.
注意:在此上下文中,JSP 表示 Java 存储过程,它是嵌入在数据库中的 Java 程序.它与 Java Server Pages 不同,后者是一种 Web 技术,因此是 JSP 首字母缩写词的更常见用法.对于造成的任何混淆,我深表歉意.
Note: In this context JSP means Java Stored Procedure, which is a Java program embedded in the database. It is not the same as Java Server Pages, which is a web technology, and hence the more common usage for the JSP acronym. I apologise for any confusion given.
这篇关于使用 Oracle 存储过程压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!