I've the Apache common codecs library & I need to invoke that in the Oracle 11 database so I can create a java source that utilize the classes inside it as below.
What are the steps to make this library included in the database?
**Code need to achieved but giving symbol Can't be found
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
jarfiles containing those dependencies (which is probably downloadable from Apache Commons Codec) and then use theloadjavautility to store them in the database so that Oracle can find them on its classpath.If you want to include the source files then you can also do that using
loadjavabut I would not recommend it for an external library as you would need to load ALL the dependencies for theBase64.javafile and this may be hundreds (or thousands) of other source files; its easier just to find the JAR where these are packaged and load that one resource (or compile the source and package a JAR of it yourself).