invoking batch script/Java code from Oracle database - java

I have a requirment, of invoking a Java file from Oracle database. In my project, whole of my business logic is in database, but there is a requirement of invoking a third party system (SOAP / RMI call) from my application.
Now for this i need to invoke atleast a Java Code or a batch script file (depending on Windows(.bat) Or Linux(.sh)).
Thanks

Try this page: http://www.cs.umbc.edu/portal/help/oracle8/java.815/a64686/04_call2.htm
You can can Java-Code from your PL/SQL.

Web-service call outs can be done from the Oracle Database. I'm not sure why you need to use Java for this as PL/SQL also allows for outbound calls using UTL_DBWS.
If you do not intend to use JPublisher, or you have a very simple web-service to consume, then you can use UTL_HTTP itself, or the appropriate class in Java - HttpURLConnection. However, I've never seen any case where a JAX-RPC library or any other web-service library was loaded into the database using loadjava, and used to make web-service calls; it ought to be possible do so, as long as the library is very light (in not depending on other libraries that cannot be loaded or used in the database), and requires permissions only to connect out from the database.
Related question
Access Web service from Oracle stored procedure

Related

Google Appengine application written in Java with access to Python+Numpy+Scipy?

I have a rather big appengine application completely written in Java. I would need to obtain results from functions completely written in python (if possible 3.x) with numpy and similar packages.
What is the best way to do it?
I'm thinking in two options.
You can write an app-engine's python module (now called services) using default or Flexible Environment. Then your default module have access to this special module via HTTP requests, synchronously via URL Fetch API or async via Push Queue API, which can only be done via *.appspot.com URLs.
Here is the official docs about module communication uses ModuleService API which resolves module addresses to *.appspot.com addresses.
You can try to execute python code using PythonInterpreter class, but i not sure if the sandbox avoid to use it.

Can I make a HTTP callout from Oracle DB via java code

Long ago I was consuming web service from Oracle DB with procedure that was generated with JPublisher. Simply providied URL of WS WSDL and JPublisher utility did the rest of procedure generation.
Now I need to make a call to REST service but with java code from Oracle DB. I googled for a while with no results. Is it possible or is it so trivial?
Yes, it is possible. You would store the HTTP command as an xml clob. You would also need to have sys access in order to add the calling user to the network ACL.

How to create Single Page Application (SPA) in java with hibernate and MySQL

I'm trying to choose best set of tools to create Single Page Applications. I would like to be able to use Java and Hibernate on server side along with MySQL. But what about ajax layer of SPA?
Maybe I have entirely wrong idea about that and Java and Hibernate make no sense in this case? But than how to implement complex server side operations?
It's rather question of UI part. The page asks a server for pages data. Java + hibernate could be used to implement service (e.g. REST service which returns data in JSON format). You can use SpringMVC to implement the service.
AJAX calls the service and process obtained data.
You can use angularJS for creating Single Page Application. this is the best framework i found for SPA development so far and using in most of projects developing which needs SPA.
for sample application refer to github
and detail about angularJS

Creating PHP website but all data retrieved through JAVA local webservices?

My plan is to set up a php-based website except all the dynamic data would be loaded through a local RESTful webservice.
The local RESTful webservices would be created using Java Jersey, which will access a MySQL database. The reason behind this is because I would like all the logic to be handled by Java.
Would this perform poorly? I have created RESTful services before and created php websites but never used them together...would calling a webservice on localhost be a terrible way to set this up?
Yes and no. If you plan to extend this beyond a website, e.g. if you plan to have other applications consume your web services, then I'd say it would be an appropriate design. Otherwise, no need for the overhead.

Calling/Using JMS from PL/SQL

Is it possible to call/use JAVA Messaging Service (JMS) from PL/SQL?
I know we can call java from pl/SQL, but calling java is different from calling JMS Queues or JMS Topics, because JMS depends upon JNDI-resource naming and when we use JNDI based resources we first have to deploy them in some J2EE container and then use them. So calling JMS always involves deploying on some J2EE container and then utilizing its functionalities.
Coming back to my question as i mentioned earlier, i want to use JMS from PL/SQL and how it would handle the deployment & JNDI-based resources stuff..?
There are two issues in your question that need to be addressed separately:
JNDI
No, calling a JMS service does not depend on having a JNDI-resource nor you need to have the JMS client deployed in a container. The reason for using JNDI within a container is to avoid having configuration parameters hard-coded in your application code (by using a "directory" of named "things".)
For example, we use JNDI to get a connection pool from which to get a jdbc connection, but I could equally create a jdbc connection directly. The later is fine for testing or for a command-line utility, but it is certainly not fine for a general case (which is why we typically opt for the former, jndi-based option.)
With JMS, yep, you indeed need JNDI, but that doesn't mean your client needs to be in a EE container. Take a look at the JMS tutorial at the Oracle/Sun site, and check the simple examples section:
http://download.oracle.com/javaee/1.3/jms/tutorial/1_3_1-fcs/doc/client.html
IIRC, every example shows clients that can be run from the command line and where you simply pass the queue name and other parameters from the command line. It should be easy to retrofit that code so that you can load them up from a property file or as parameters in a function call.
Java in Store Procedures
Once you have a command-line client that can access the JMS queue you want to access to, you can retrofit that code so that it runs as a stored procedure. Yes, you can use Java to write stored procedures with Oracle...
... now, I think that is a horrible feature, one that is way too open to abuse. But, if you have a legitimate need to access a JMS provider from PL/SQL, this would be one way to go.
First, convert your command-line jms client into a stored procedure. Check the existing documentation on how to create java-based stored procedures with Oracle.
http://www.stanford.edu/dept/itss/docs/oracle/10g/java.101/b12021/storproc.htm
http://download.oracle.com/docs/cd/B10501_01/java.920/a96659.pdf
Then have your PL/SQL code call the stored procedure just as they would call any other stored proc or SQL statement. And voila.
Parting Thoughts
I've never done any of this, and there might be problems along the way. However, at least conceptually, it should be possible. At the very least you should be able to create a jms command-line utility that you can then convert into a java-based stored proc.
edit
Apparently Oracle has something called "Oracle Advanced Queueing" where you can access a JMS provider directly via PL/SQL.
http://www.akadia.com/services/ora_advanced_queueing.html
http://technology.amis.nl/blog/2384/enqueuing-aq-jms-text-message-from-plsql-on-oracle-xe
http://download.oracle.com/docs/cd/B10500_01/appdev.920/a96587/qintro.htm
Looks like a lot of reading and elbow grease involved, but it is certainly feasible (assuming you are using the right Oracle version.)
I might be updating an old thread, but I just successfully used JMS to send out messages from a PLJava trigger function. The one requirement that I never found written anywhere, is you have to load the jms broker jar files(I used activemq) in your database through pljava install function. Other procedures are same as this example.

Categories