gpt4 book ai didi

java - 将 Apache Commons Codec 添加到 Oracle 数据库的步骤

转载 作者:行者123 更新时间:2023-12-01 18:35:14 30 4
gpt4 key购买 nike

我有 Apache 通用编解码器库,我需要在 Oracle 11 数据库中调用它,以便我可以创建一个使用其中类的 java 源,如下所示。

使该库包含在数据库中的步骤是什么?

Java file needs to be included in Oracle DB

**需要实现代码,但找不到给出的符号

CREATE OR REPLACE JAVA SOURCE NAMED "org_apache_Base64" AS
import java.lang.*;
import java.sql.*;
import oracle.sql.*;
import java.io.*;
import javax.xml.bind.DatatypeConverter;
import org.apache.commons.codec.binary.Base64;

public class org_apache_Base64
{
public static void ExportBlob(String CONTFILE, BLOB CONTBLOB) throws Exception
{
try
{
File file = new File("/u01/oracle/jam_export/contract1");
FileOutputStream fos = new FileOutputStream(file);
byte[] encodedBytes = Base64.getEncoder().encode("Test".getBytes());
System.out.println("encodedBytes " + new String(encodedBytes));
byte[] decodedBytes = Base64.getDecoder().decode(encodedBytes);
System.out.println("decodedBytes " + new String(decodedBytes));
System.out.println("PDF File Saved");
fos.write(decoded);
fos.flush();
fos.close();
}
catch (Exception e)
{
System.out.println(e);
}
} };

最佳答案

Find the jar files包含这些依赖项(可能可以从 Apache Commons Codec 下载),然后使用 loadjava utility将它们存储在数据库中,以便 Oracle 可以在其类路径中找到它们。

loadjava -user USERNAME/PASSWORD@SID name_of_jar_file.jar

如果您想包含源文件,那么您也可以使用 loadjava 来实现,但我不建议将其用于外部库,因为您需要加载ALL Base64.java 文件的依赖项,这可能是数百(或数千)个其他源文件;只需找到打包这些资源的 JAR 并加载该资源(或者自己编译源代码并打包一个 JAR)就更容易了。

关于java - 将 Apache Commons Codec 添加到 Oracle 数据库的步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60074235/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com