7 Replies Latest reply: Feb 17, 2014 7:46 PM by JustinCave RSS

    Reg: Calling Java methods from db -

    ranit B

      Hi Experts,

       

      I got few doubts regarding calling Java methods/packages from Oracle db:

       

      1. Is there any particular reason why this feature was provided?

      2. Do we get any performance improvement if we implement say the logic of a PL/SQL program in Java and call this feature?

      3. Can this feature be used to leverage the powerful features of Java in Oracle?

       

      Here - Calling Java Methods in Oracle Database

       

      Neither have personally worked on this thing before, nor have heard of this in Oracle blogs/articles. Just curious about it.

       

      Please advise.

       

      -- Ranit

      ( on Oracle 11.2.0.2.0 )

        • 1. Re: Reg: Calling Java methods from db -
          ranit B

          Was reading/googling more and just found this nice link -- Developing Java Stored Procedures

           

          Also, read this:

          Productivity and Ease of Use

          By designing applications around a common set of stored procedures, you can avoid redundant coding and increase the productivity. Moreover, stored procedures let you extend the functionality of the database.

          You can use the Java integrated development environment (IDE) of your choice to create stored procedures. They can be called by standard Java interfaces, such as Java Database Connectivity (JDBC), and by programmatic interfaces and development tools, such as SQLJ, Oracle Call Interface (OCI), Pro*C/C++, and JDeveloper.

           

          This broad access to stored procedures lets you share business logic across applications. For example, a stored procedure that implements a business rule can be called from various client-side applications, all of which can share that business rule. In addition, you can leverage the Java facilities of the server while continuing to write applications for a preferred programmatic interface.

           

          Am I on right track? Please guide me to understand this.

          • 3. Re: Reg: Calling Java methods from db -
            rp0428
            I got few doubts regarding calling Java methods/packages from Oracle db:

            Ok - what are they? Why didn't you post your 'doubts' so we can try to address them?

            1. Is there any particular reason why this feature was provided?

            Every feature is a tool. Use the best tool for the job you have to do.

            2. Do we get any performance improvement if we implement say the logic of a PL/SQL program in Java and call this feature?

            There IS no answer to that question. It all depends on both the job that needs to be done and how you use the tool to do that job.

             

            The best combination is to use the right tool for the job and to use the tool properly. If Java is the better tool for the job you can likely get performance improvements using Java properly to do the job.

            3. Can this feature be used to leverage the powerful features of Java in Oracle?

            Seriously? Don't you think that is the main purpose in adding a new feature to begin with?

             

            Java has LOTS of functionality to deal with the file system. Need to get a list of files from a directory? Java does that easily.

             

            Java has LOTS of functionality to work with arrays and/or nested arrays of data.

            • 4. Re: Reg: Calling Java methods from db -
              ranit B

              SB,

              Thanks for the link. But, I felt it was more about the debate between JAVA and Oracle techno.

               

              Specifically speaking, my doubt was more about -- can we use this JAVA feature to implement new efficient algorithms for existing utilities?

              Say, something which can be extreme efficient for processing huge data in range of GBs or say big data.

               

              I have not seen much use of this feature anywhere, not even in blogs (don't know why).

               

              Thanks!

              • 5. Re: Reg: Calling Java methods from db -
                ranit B

                RP,

                Thanks for your inputs.

                Ok - what are they? Why didn't you post your 'doubts' so we can try to address them?

                You already addressed my doubts - 1,2 and 3 in your reply.

                Every feature is a tool. Use the best tool for the job you have to do.

                Agreed. But, I am not aware of this feature uses. Read about it in docs but still not sure where it can be used best.

                Java has LOTS of functionality to deal with the file system. Need to get a list of files from a directory? Java does that easily.

                 

                Java has LOTS of functionality to work with arrays and/or nested arrays of data.

                Thanks. I wanted something like this only. Could you please add some more points on this?

                Where else this feature can be used?

                 

                -- Ranit

                • 6. Re: Reg: Calling Java methods from db -
                  ranit B

                  Where else can the Java feature be best used in Oracle?

                   

                  Any advise on this.

                  • 7. Re: Reg: Calling Java methods from db -
                    JustinCave

                    It's not really practical to try to list all the things that one can do in Java that one cannot (easily) do in PL/SQL.  There are millions of Java libraries out there that do all manner of different things.  Implementing SFTP and writing to binary XLS files, for example.  A number of new packages that Oracle have introduced (many of the XML packages, for example) were originally written in Java before being reimplemented in later releases more efficiently.

                     

                    As with anything else, though, this is largely driven by your particular application's particular requirements.  Most apps don't really need to resort to Java (or .Net) stored procedures.  When you do have the need, though, it's quite useful to be able to grab a random Java package that implements the API you need.

                     

                    Justin