Oracle and Java

HiIs there anyway by which i can store my java class inside the oracle database.If anyone has a iota of idea about this then please share it with me.Thanks Sandeep Saluja
[206 byte] By [sandeep_saluja] at [2007-9-26 4:31:42]
# 1
sure you have to take a look at the loadjava and dropjava commands.
adamrau at 2007-6-29 17:45:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
see, http://www.bookpool.com/.x/mkbwi5hgrn/sm/0072124423
mchan0 at 2007-6-29 17:45:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Why would you want to store a class within a database. Saving an object makes sense, but a class?
stewiestyle at 2007-6-29 17:45:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Hi adamthanks.but can you please elaborate on loadjava and dropjava commands.ThanksSandeep
sandeep_saluja at 2007-6-29 17:45:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
if you don't want to read up, at least do a google search, http://lbdwww.epfl.ch/f/teaching/courses/oracle/java.815/a64686/toc.htmmay not be one of the best but it is a start. you have to do some research yourself!
mchan0 at 2007-6-29 17:45:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

HOPE THIS HELPS.

Overview

--

This article describes the use of the loadjava and dropjava utilities that

are used to load and unload java schema objects to and from an Oracle 8i

database. It is intended to be used by java developers who are creating java

applications that will run in the Oracle 8i database, such as java stored

procedures, CORBA servers, or EJB.

Before the java classes can run in the Oracle 8i Java Virtual Machine, they

must be loaded into the database as java schema objects. The 'loadjava'

utility loads java classes, sources, or resource files into the database and

creates java schema objects.

loadjava Utility

-

The loadjava tool creates schema objects from files and loads them into a

schema. Schema objects can be created from Java source files, class files,

and resource files, and the same types of files in uncompressed ZIP and Java

archives (JARs).

loadjava can also create schema objects from SQLJ files. The "Oracle8i SQLJ

Developer's Guide and Reference" manual, (A64684-01), describes how to use

loadjava with SQLJ. You must have the CREATE PROCEDURE privilege to load

into your schema, and the CREATE ANY PROCEDURE privilege to load into another

schema.

When schema objects are created, loadjava checks if any classes referenced by

a loaded class are valid schema objects. This is known as resolution.

loadjava 'resolves' classes references to other classes using a resolver spec.

This is analogous to the CLASSPATH environment variable used by the javac

compiler outside of the database when it needs to find classes referenced by

the class being compiled.

For more information on resolution and resolver specs, refer to the

"Enterprise Java Beans and CORBA Developer's Guide", (A64683-01), or the

"Oracle8i Java Developer's Guide", (A64682-01).

loadjava invokes the javac compiler within the database when java source is

loaded before it creates the java schema object. It also invokes the javac

compiler if loaded classes refer to other classes that have source loaded but

do not have a class created from the source, yet. This guarantees that a class

refers to the latest loaded version of another java class and guarantees

that only 'valid' java classes are used during the resolution phase of loading. This

feature is much like the build-avoidance feature of the UNIX

make utility.

For more information on compilation and java schema object validity, refer

to the "Enterprise Java Beans and CORBA Developer's Guide" or the "Oracle8i

Java Developer's Guide".

Syntax for loadjava

-

The syntax for using loadjava is as follows:

loadjava {-user | -u} <user>/<password>[@<database>] [options]

<file>.java | <file>.class | <file>.jar | <file>.zip |

<file>.sqlj | <resourcefile>} ...

[{-a | -andresolve}]

[-debug]

[{-d | -definer}]

[{-e | -encoding} <encoding_scheme>]

[{-f | -force}]

[{-g | -grant} {<user> | <role>}[,{<user> | <role>}]...]

[{-o | -oci8}]

[-oracleresolver]

[{-r | -resolve}]

[{-R | -resolver} "resolver_spec"]

[{-S | -schema} <schema>]

[{-s | -synonym}]

[{-t | -thin}]

[{-v | -verbose}]

where:

<filenames> You can specify any number and combination of .java, .class,

.sqlj, .jar .zip, and resource file name arguments in any order.

JAR and ZIP files must be uncompressed.

-andresolve Directs loadjava to compile sources if they have been loaded and

to resolve external references in each class as it is loaded.

-andresolve and -resolve are mutually exclusive; if neither is

specified, then loadjava loads source or class files but does not

compile or resolve them.

-debugDirects the Java compiler to generate debug information which is

equivalent to javac -g.

-definerBy default, class schema objects run with the privileges of their

invoker. This option confers definer (the developer who invokes

loadjava) privileges upon classes instead. This option is

conceptually similar to the Unix setuid facility.

-encodingIdentifies the source file encoding for the compiler, overriding

the matching value, if any, in the JAVA$OPTIONS table. Values

are the same as for the javac -encoding option. If you do not

specify an encoding on the command line or in a JAVA$OPTIONS

table, the encoding is assumed to be latin1. The -encoding

option is relevant only when loading a source file.

-forceForces files to be loaded even if they match digest table

entries.

-grantGrants the EXECUTE privilege on loaded classes to the listed

users and/or roles. To call the methods of a class, users must

have the EXECUTE privilege. Any number and combination of user

and role names can be specified, separated by commas but not

spaces (-grant Bob,Betty not -grant Bob, Betty).

Note: -grant is a "cumulative" option; users and roles are added

to the list of those with the EXECUTE privilege. To remove

privileges, either drop and reload the schema object with the

desired privileges, or change the privileges with the SQL REVOKE

command.

To grant the EXECUTE privilege on an object in someone else's

schema requires that the original CREATE PROCEDURE privilege was

granted with WITH GRANT options.

-oci8Directs loadjava to communicate with the database using the OCI

JDBC driver. -oci8 and -thin are mutually exclusive. If neither

is specified, then -oci8 is used by default. Choosing -oci8

implies the syntax of the -user value.

-oracleresolver

Shorthand for:

-resolver '((* definer's_schema) (* public))'

-oracleresolver is the default and is mutually exclusive

with -resolver. -oracleresolver detects missing classes

immediately. Use -oracleresolver (or do not specify

-resolver) except when you want to test a class regardless

of its unresolved references.

-resolveCompiles (if necessary) and resolves external references in

classes after all classes on the command line have been loaded.

-andresolve and -resolve are mutually exclusive; if neither is

specified, then loadjava loads files but does not compile or

resolve them.

-resolverSpecifies an explicit resolver spec, which is bound to the newly

loaded classes. -resolver is mutually exclusive with

-oracleresolver.

-schemaDesignates the schema where schema objects are created. If not

specified, the logon schema is used. To create a schema object

in a schema that is not your own, you must have the CREATE

PROCEDURE or CREATE ANY PROCEDURE privilege.

-synonymCreates a PUBLIC synonym for loaded classes making them

accessible outside the schema into which they are loaded. To

specify this option, you must have the CREATE PUBLIC SYNONYM

privilege. If -synonym is specified for source files, classes

compiled from the source files are treated as if they had been

loaded with -synonym.

-thinDirects loadjava to communicate with the database using the thin

JDBC driver. -oci8 and -thin are mutually exclusive; if neither

is specified, then -oci8 is used by default. Choosing -thin

implies the syntax of the -user value.

-userSpecifies a user, password, and database connect string. The

files are loaded into this database instance. The argument

has the form <username>/<password>[@<database>].

-verboseDirects loadjava to emit detailed status messages while running.

Use -verbose to learn when loadjava does not load a file because

it matches a digest table entry.

Examples:

loadjava -u scott/tiger -resolve -schema TEST ServerObjects.jar

loadjava -thin -u scott/tiger@dbhost:5521:orcl \

-andresolve alpha.class beta.props

loadjava -thin -schema test -u scott/tiger@localhost:5521:orcl \

-grant Betty,Bob alpha.class

Syntax for dropjava

-

The dropjava tool is the converse of loadjava.

Syntax for the use of dropjava is as follows:

dropjava {-u | -user} <user>/<password>[@<database>] [options]

{<file>.java | <file>.class | file.sqlj |

<file>.jar | <file.zip> | <resourcefile>} ...

[{-o | -oci8}]

[{-S | -schema} <schema>]

[{-t | -thin}]

[{-v | -verbose}]

where:

-userSpecifies a user, password, and optional database connect string

The files are dropped from this database instance.

<filenames>

You can specify any number and combination of .java, .class,

.sqlj, .jar, .zip, and resource file names in any order. JAR and

ZIP files must be uncompressed.

-oci8Directs dropjava to connect with the database using the oci8 JDBC

driver. -oci8 and -thin are mutually exclusive. If neither is

specified, then -oci8 is used by default. Choosing -oci8 implies

the form of the -user value. See "user" for details.

-schemaDesignates the schema from which schema objects are dropped. If

not specified, the logon schema is used. To drop a schema object

from a schema that is not your own, you need the DROP ANY

PROCEDURE system privilege.

-thinDirects dropjava to communicate with the database using the thin

JDBC driver. -oci8 and -thin are mutually exclusive. If neither

is specified, then -oci8 is used by default. Choosing -thin

implies the form of the -user value.

-verboseDirects dropjava to emit detailed status messages while running.

Examples:

dropjava -u scott/tiger -schema TEST ServerObjects.jar

dropjava -thin -u scott/tiger@dbhost:5521:orcl alpha.class beta.props

Related Documents

--

Detailed documentation on the use of 'loadjava' can be found in the

following manuals:

"Enterprise Java Beans and CORBA Developer's Guide", (A64683-01),

Tools chapter

"Oracle8i Java Developer's Guide", (A64682-01), Appendix A

"Java Stored Procedures Developer's Guide", (A64686-01)

.

adamrau at 2007-6-29 17:45:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
Thanks a lot to both adam and mchan0.i am ready to do any research . i luv java so much buddy. Java is something which can keep me awake for million of years.Thanks Sandeep
sandeep_saluja at 2007-6-29 17:45:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

yes u can by using the setObject() of ResultSet. For instance take an Employee class then u can store the objects of this class using setObject() and ur corresponding database table must create an object of type Employee somewhat like this...

CREATE TYPE EMPLOYEE AS .....

CREATE TABLE EMP (EMPLOYEE .....

babloosony at 2007-6-29 17:45:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...