How to insert a java class into oracle.
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: How to insert a java class into oracle.

  1. #1
    Join Date
    Mar 2001
    Posts
    19

    Exclamation

    I have a serialized Java class and i want to insert this class in a oracle table. What is the datatype i should use and how shall do a insert statement.

    I have created a table named test with

    id number(9)
    value long raw

    when i insert a null it works fine but when i try to insert a serialized java class like this

    Serialized se = new Serialized();
    insert into test
    values(1, se) it gives me an error saying that column not found.

    Can anyone help me out how to insert a java class in Oracle

  2. #2
    Join Date
    Mar 2001
    Posts
    314
    Use LOADJAVA utility.

    -amar

  3. #3
    Join Date
    Jun 2000
    Location
    Chennai/India
    Posts
    90
    yeah, how do we use that utility ???
    Thanks & Regards
    Ganesh .R
    A Winner never Quits, A Quitter never Wins
    Ganesh .R

  4. #4
    Join Date
    Mar 2001
    Posts
    314
    From the 8i Java Tools reference:

    --------- begin quote
    The loadjava tool creates schema objects from files and loads them into a schema. Schema objects can be created from Java source, class, and data files. loadjava can also create schema objects from SQLJ files; the Oracle8i SQLJ Developer's Guide and Reference describes how to use loadjava with SQLJ.

    You must have the following SQL database privileges to load classes:

    CREATE PROCEDURE and CREATE TABLE privileges to load into your schema.

    CREATE ANY PROCEDURE and CREATE ANY TABLE privileges to load into another schema.

    oracle.aurora.security.JServerPermission.loadLibraryInClass.. See the "Database Contents and JVM Security" section in Chapter 5 of the Oracle8i Java Developer's Guide for more information.

    You can execute the loadjava tool either through the command line (as described below) or through the loadjava method contained within the DBMS_JAVA class. To execute within your Java application, do the following:

    call dbms_java.loadjava('... options...');


    where the options are the same as specified below. Each option should be separated by a blank. You should not separate the options with a comma. The only exception for this is the -resolver option, which contains blanks. For -resolver, you should specify all other options first, a comma, then the -resolver option with its definition. You should not specify the following options as they relate to the database connection for the loadjava command-line tool: -thin, -oci8, -user, -password. The output is directed to stderr. Set serveroutput on and call dbms_java.set_output as appropriate.


    --------------------------------------------------------------------------------
    Note:
    The loadjava tool is located in the bin subdirectory under $ORACLE_HOME.

    --------------------------------------------------------------------------------




    Syntax
    loadjava {-user | -u} /[@] [options]
    .java | .class | .jar | .zip |
    .sqlj | ...
    [-debug]
    [-d | -definer]
    [-e | -encoding ]
    [-f | -force]
    [-g | -grant [, ]...]
    [-help]
    [-nohelp]
    [-o | -oci8]
    [ -order ]
    [-noverify]
    [-r | -resolve]
    [-R | -resolver "resolver_spec"]
    [-S | -schema ]
    [ -stdout ]
    [-s | -synonym]
    [-tableschema ]
    [-t | -thin]
    [-v | -verbose]

    Argument Summary
    Table 1-2 summarizes the loadjava arguments. If you execute loadjava multiple times specifying the same files and different options, the options specified in the most recent invocation hold. There are two exceptions:

    If loadjava does not load a file because it matches a digest table entry, most options on the command line have no effect on the schema object. The exceptions are -grant, and -resolve, which are always obeyed. Use the -force option to direct loadjava to skip the digest table lookup.

    The -grant option is cumulative; every user specified in every loadjava invocation for a given class in a given schema has the EXECUTE privilege. You cannot grant to a role; you can only grant to specified schemas or users.

    Table 1-2 loadjava Argument Summary
    Argument Description

    You can specify any number and combination of .java, .class, .sqlj, .ser, .jar .zip, and resource file name arguments in any order.

    -debug
    Turns on SQL logging and is equivalent to javac -g.

    -definer
    By 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.)

    -encoding
    Identifies 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.

    -force
    Forces files to be loaded even if they match digest table entries.

    -grant
    Grants the EXECUTE privilege on loaded classes to the listed users. (To call the methods of a class, users must have the EXECUTE privilege.) Any number and combination of user names can be specified, separated by commas but not spaces (-grant Bob,Betty not -grant Bob, Betty). Note: -grant is a "cumulative" option; users 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. Also, you cannot grant to a role. All grants must be explicit in granting to specific users.

    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.

    Note: You must uppercase the schema name.

    -help
    Prints the usage message on how to use the loadjava tool and its options.

    -nohelp
    Suppresses the usage message that is given if either no option is specified or if the -help option is specified.

    -noverify
    Causes the classes to be loaded without bytecode verification. You must be granted oracle.aurora.security.JServerPermission(Verifier) to execute this option. In addition, this option must be used in conjunction with -r.

    -oci8
    Directs loadjava to communicate with the database using the OCI JDBC driver. -oci8 and -thin are mutually exclusive; if neither is specified -oci8 is used by default. Choosing -oci8 implies the syntax of the -user value. You do not need to provide the URL.

    -order
    Directs loadjava load the classes in an order that facilitates resolution of those classes. Classes are loaded in a manner where any dependent class is loaded before the class that includes it as a dependency.

    -resolve
    Compiles (if necessary) and resolves external references in classes after all classes on the command line have been loaded. If you do not specify -resolve, loadjava loads files but does not compile or resolve them.

    -resolver
    Specifies an explicit resolver spec, which is bound to the newly loaded classes. If -resolver is not specified, the default resolver spec, which includes current user's schema and PUBLIC, is used. See "resolver" in this section for details.

    -schema
    Designates 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. You must have CREATE TABLE or CREATE ANY TABLE privilege. Finally, you must have the JServerPermission.loadLibraryInClass for the class.

    -stdout
    Causes the output to be directed to stdout, rather than to stderr.

    -synonym
    Creates 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.

    -tableschema
    Creates the loadjava internal tables within this specified schema, rather than in the Java file destination schema.

    -thin
    Directs 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. You do need to specify the appropriate URL through the -user option.

    -user
    Specifies a user, password, and database connect string; the files will be loaded into this database instance. The argument has the form /[@].

    -verbose
    Directs 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.
    -------------- end quote

    -amar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width