2

We have a very old application with a complex installation process that relies on Oracle's loadjava client application. loadjava was included with Oracle's client up until 12c but now that we are upgrading to 19c I don't see it included in any of the Oracle clients here https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html

I am aware that it is still available on the server, but given the nature of our application that is of little use to me without significant pain.

Am I missing something? What are my options to get loadjava running from my Oracle client? I see there is a a DBMS_JAVA package available https://docs.oracle.com/en/database/oracle/oracle-database/21/jjdev/DBMS-JAVA-package.html - would that help?

Here is an example of how our application currently uses loadjava. This is called from an OS exec call from our application during installation. We use it just to load a handful of SQLj files.

loadjava -verbose -user USER/PASS@//localhost:1521/ORCLPDB1 /java/utils-oracle.sqlj
TrojanName
  • 4,853
  • 5
  • 29
  • 41
  • What is loadjava? How did you use it in the path? Did you search in Oracle release notes when it changed and what is the recommended migration path? – aled Jul 03 '23 at 16:50
  • 1
    @aled Loadjava is a utility that allows you to embed Java classes and packages into the database so that they can be wrapped with PL/SQL functions and called from SQL and PL/SQL code. – MT0 Jul 03 '23 at 16:59
  • If it does not exist on the client but does exist on the server then transfer the java classes or JAR files to the server (i.e. using FTP, SSH, etc.) and then use `loadjava` from the server. – MT0 Jul 03 '23 at 17:02

2 Answers2

3

You can use:

  • CREATE [AND COMPILE] JAVA SOURCE
    
    To compile the java directly from source code in SQL.
  • The database package and procedure
    DBMS_JAVA.LOADJAVA
    
    To use loadjava from within the database.
  • Transfer the Java classes and packages to the server and use the loadjava utility on the server.
  • Download the full Oracle database client (as mentioned by kfinity)
MT0
  • 143,790
  • 11
  • 59
  • 117
  • thanks very much for the response. Moving the files to the server isn't an option for me, as the existing calls to loadjava are made during a front end application build process. Neither is using the full client as I explained to kfinity. I've edited my question and added an example of how we call loadjava. Which of your recommended approaches would you say is best to load a handful of SQLj files from the frontend Oracle client? – TrojanName Jul 04 '23 at 09:25
  • 1
    @TrojanName Oracle stopped supporting SQLj inside the database from Oracle 12.2. You will not be able to run SQLj in Oracle 19 and will need to [convert the files to use JDBC](https://stackoverflow.com/a/72970400/1509264). – MT0 Jul 04 '23 at 09:54
  • 1
    Additionally, I'm sure you could move files to the server and then run `loadjava` from the server as part of the front-end build process if you create a script to use FTP or SSH to transfer the files and then use that script to run the utility on the server. However, I would question whether this should be part of the front-end build script or should be part of a separate back-end build process. – MT0 Jul 04 '23 at 09:56
  • Oh wow, I didn't know Oracle stopped supporting SQLj - thank you! The joy of legacy code ;) I'm a little confused now though - if Oracle have stopped supporting SQLj then why would calling loadjava from the server even work? I will definitely look into JDBC if loadjava is off the table – TrojanName Jul 04 '23 at 10:34
  • 1
    @TrojanName Using `loadjava` will load the java code into the database independently of whether the Java code compiles, has valid syntax or does what you want (you can pass options to it to compile it as you load it but the default options just insert it into the database). Yes, you will need to update the code from SQLj to JDBC but once you do that then you can use `loadjava` (with code that will compile) either on the server, client or using the `DBMS_JAVA` package (or just compiling the code directly with `CREATE JAVA`). – MT0 Jul 04 '23 at 10:39
  • Super, all is clear. I see that your linked answer has a nice example too of using JDBC. Thanks again for excellent advice. – TrojanName Jul 04 '23 at 11:08
2

As far as I know, the Oracle Java VM (Aurora - which includes the loadjava script and Java class) is not included in the Oracle Instant Client. You need the full Oracle Database Client, which you can download from the Oracle Software Delivery Cloud. It requires you to create an Oracle login if you don't already have one.

On the search page, select "Release" and then type "Oracle Database Client". It's a significantly larger download - the full client is 1.3 GB for Oracle Database 12.2, vs the instant client at 68 MB.

kfinity
  • 8,581
  • 1
  • 13
  • 20
  • 1
    You don't have to install the *full* Oracle Client. Run the Oracle Universal Installer custom installation and select component ***Utilities***, then you get the `loadjava` tool – Wernfried Domscheit Jul 04 '23 at 06:35
  • @kfinity thanks for this idea, but seeing as this issue during the process of trying to Dockerize our ancient application, that would massively increase the container size, just for a once-off operation to load 3 SQLj files. I appreciate the response though. – TrojanName Jul 04 '23 at 09:03