0

I want to run following command under Windows with Oracle Database 12c installed:

loadjava -force -genmissing -r -user username/password@database -verbose core-1.7.jar

The problem is that I use Windows authentication and I connect the following way:

sqlplus / as sysdba

and I do not enter any username or password. Could you please tell me how to execute first command under Windows for a pluggable database?

  • 2
    core-1.7.jar ??? I hope you are not trying to upgrade/downgrade the JVM that is inside the DB. Also, have you tried using SQL*Developer to load the jar? – Michael Kutz Nov 2 '18 at 16:50
  • I am following this guide community.oracle.com/message/13360407#13360407 so as to be able to generate QR codes on demand. I didn't know I can. Will look that online. – tweant Nov 2 '18 at 22:19
  • Connecting the way you do is strictly only exclusively for DBA tasks (like starting up and shutting down your database. You never ever use that to connect to the database for any other use - specifically not for running or developing applications. You always connect as a specific user. – Albert Godfrind Nov 5 '18 at 8:51
0

You should not use SYS for this.

With a regular user, you can simply provide the username/password@address.

To do this with SYS, without the password:

Create the class:

C:\Users\Administrator>copy con Hello.java
public class Hello
{
    public static String world()
    {
    return "Hello World";
    }
}
^Z
        1 file(s) copied.

C:\Users\Administrator>type Hello.java
public class Hello
{
    public static String world()
    {
    return "Hello World";
    }
}

C:\Users\Administrator>set JAVA_HOME=O:\oracle\base\product\12.2.0\dbhome_1\jdk

C:\Users\Administrator>set PATH=%JAVA_HOME%\bin;%PATH%

C:\Users\Administrator>javac Hello.java

C:\Users\Administrator>jar cvf Hello.jar Hello.class
added manifest
adding: Hello.class(in = 273) (out= 209)(deflated 23%)

Connect to pluggable database without password:

C:\Users\Administrator>sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Fri Nov 9 16:18:34 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> alter session set container=pdb1;

Session altered.

Load the class:

SQL> exec dbms_java.loadjava('C:\Users\Administrator\Hello.jar');

PL/SQL procedure successfully completed.

SQL> select owner, object_name, object_type, status, created
     from dba_objects where object_name = 'Hello';

OWNER      OBJECT_NAM OBJECT_TYPE             STATUS  CREATED
---------- ---------- ----------------------- ------- ---------
SYS        Hello      JAVA CLASS              INVALID 09-NOV-18

SQL> alter java class "Hello" compile;

Java altered.

SQL> select owner, object_name, object_type, status, created
     from dba_objects where object_name = 'Hello';

OWNER      OBJECT_NAM OBJECT_TYPE             STATUS  CREATED
---------- ---------- ----------------------- ------- ---------
SYS        Hello      JAVA CLASS              VALID   09-NOV-18

Clean up the mess:

SQL> drop java class "Hello";

Java dropped.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.