In the past I've used the following to extract the java class files from a database:
DROP TABLE java_class_blob ;
CREATE TABLE java_class_blob (
longname varchar2 ( 2000 ),
blob_object blob ) ;
CREATE FUNCTION temp_get_java_class (
a_object_name varchar2,
a_object_schema varchar2 )
RETURN blob
AS
b blob ;
BEGIN
dbms_lob.createtemporary ( b, false ) ;
dbms_java.export_class ( a_object_name, a_object_schema, b ) ;
RETURN b ;
END ;
/
INSERT INTO java_class_blob (
longname,
blob_object )
SELECT dbms_java.longname ( object_name ) AS longname,
temp_get_java_class ( object_name, owner )
FROM dba_objects
WHERE object_type = 'JAVA CLASS'
AND owner = 'TEMPO' ;
COMMIT ;
DROP FUNCTION temp_get_java_class ;
Followed by the extracting the blobs using:
#!/usr/bin/env perl
use strict;
use warnings;
use DBD::Oracle qw(SQLT_BIN ORA_BLOB);
use utf8;
my ( $database, $user ) = @ARGV;
my $dbh = get_db_connection($database, $user);
$dbh->{LongTruncOk} = 0;
my $obj_query = q{
SELECT longname,
dbms_lob.getlength (blob_object)
FROM java_class_blob
};
my $obj_list = $dbh->selectall_arrayref($obj_query);
my $blob_query = q{
SELECT blob_object
FROM java_class_blob
WHERE longname = ?
};
foreach my $obj (@{$obj_list}) {
my ($longname, $length) = @{$obj};
$dbh->{LongReadLen} = $length;
my $sth_obj = $dbh->prepare($blob_query);
$sth_obj->execute($longname);
my ($blob) = $sth_obj->fetchrow();
next unless ($blob) ;
my $classfile = 'JAVA_CLASS/' . $longname . '.class';
my $dirname = 'JAVA_CLASS/' . $longname;
$dirname =~ s|/[^/]+$||;
( -d $dirname) || `mkdir -p $dirname` ;
open my $fh, '>:raw', $classfile ;
print $fh $blob;
close $fh;
}