Help with use of Java Stored Procedures to invoke Java Code within Applicat
Good afternoon everyone
Our development team is looking for some assistance/validation of a design strategy we are deploying for a client. Let me first layout the environment and then the design issue at hand:
Business User Workstation component: Oracle SQL*Developer 1.5.x
Reporting Tool: Actuate e.Spreadsheet A10
Application Web UI: J2EE application developed with Eclipse
Application Scripting: Application has a scripting component whereby business users can write Oracle PL/SQL to perform many of the functions that are available in the Web UI, but can be batched up or repeated several times.
Application Server WebLogic 9.2.3 (client constraint)
Database Serve: Oracle 11g, Release 11.1.0.7
Lots of other stuff included but irrelevant for this conversation.
Here's the scenario in question:
1. Through the scripting solution, the application user must use PL/SQL to invoke functionality within the Web UI. All PL/SQL that the application user creates does not contain any SQL. Instead our security model mandates that “pre-defined” routines will perform all of the SQL operations against the database; the application user simply invokes the stored procedures of functions to perform activities in the database.
2. There is a component of the scripting application that facilitates the creation of reports. In our application, we are using Actuate’s e.Spreadsheet Engine to create the report and format the report based on a template. The template is provided as input, as well as other data items, into Actuate for processing. The net result is the report is created by the Actuate e.Spreadsheet engine in pdf format and then sent back to the user for distribution to other users in the company.
3. The Actuate e.Spreadsheet engine consists of one or more JAR files within the Application Server framework. The Web UI utilizes these JAR files as well to perform report generation and data manipulation activities. In the case of the reporting functionality, the pdf report that is generated by Actuate is returned into either the Web UI or into the scripting component for persistence in the database. The mechanism exists to create multi-step jobs that can create multiple reports in one run.
4. So to facilitate the above, we are creating one or more Java Stored Procedures that will mediate the communication between the PL/SQL the user’s create and the Java components that are required for business processing. PL/SQL will invoke one or more Java Stored Procedures. Then the Java Stored Procedures invoke Actuate e.Spreadsheet, generate the report, saves the report in the database and returns control back to the invoking procedure.
So the question is: Is this a viable and correct use of Oracle Java Stored Procedures. What are the advantages/disadvantages of doing so? Any security issues or potholes that you can think of? Tuning issues for the JVMs? Any white papers that you can think of?
For any Oracle employees that respond, material such as Oracle Whitepapers, etc. would be great.
I can be contacted at (313) 227-4350 or at [email protected]
Thanks in advance.
So are you planning on loading the entire e.Spreadsheet engine into the database server's JVM?
If so, I would expect that to work, but I expect that you'd have some performance issues. I'd expect that the process of building these PDFs is going to be relatively expensive. Tuning the database server's JVM tends to be rather more challenging than tuning JVM's in an app server.
If not, I'm not sure how the Java stored procedure would invoke the e.Spreadsheet engine on the application server. It is possible to use Oracle AQ to send a JMS message, but I don't think you can use the standard J2EE JMS APIs-- I think you'd have to use Oracle's AQ interface.
Justin
Similar Messages
-
Invoking "java myClass" using Runtime.Exec from a Java Stored Procedure
Hi All,
This is regarding the use of Runtime.getRunTime().exec, from a java programme (a Java Stored Procedure), to invoke another Java Class in command prompt.
I have read many threads here where people have been successuful in invoking OS calls, like any .exe file or batch file etc, from withing Java using the Runtime object.
Even i have tried a sample java programme from where i can invoke notepad.exe.
But i want to invoke another command prompt and run a java class, basically in this format:
{"cmd.exe","java myClass"}.
When i run my java programme (in command prompt), it doesnt invoke another command prompt...it just stays hanging.
When i run the java programme from my IDE, VisualCafe, it does open up a command prompt, but doesnt get the second command "java myCLass".
Infact on the title of the command prompt (the blue frame), shows the path of the java.exe of the Visual Cafe.
and anyway, it doesnt run my java class, that i have specified inside the programme.
Even if i try to run a JAR file, it still doesnt do anything.
(the JAR file other wise runs fine when i manually invoke it from the command prompt).
Well, my question is, actually i want to do this from a Java Stored Procedure inside oracle 8.1.7.
My feeling is, since the Java Stored Procedure wont be running from the command prompt (i will be actually invoking it through a Oracle trigger), it may be able to invoke the command prompt and run the java class i want. and that java class has to run with the SUn's Java, not Oracle JAva.
Does any one have any idea about it?
Has anyone ever invoked a java class or JAR file in command prompt from another Java Programme?
YOur help will be highly appreciated.
(P:S- Right now, my database is being upgraded, so i havent actually been able to create a Java Stored procedure and test it. But i have tested from a normal java programme running in command prompt and also from Visual Cafe).
Thanks in advance.
-- Subhasree.Hello Hari,
Thanks for your quick reply.
Can you please elaborate a little more on exactly how you did? may be just copy an dpaste taht part of teh code here?
Thanks a lot in advance.
--Subhasree -
Invoking Unix command with java stored procedure
Hi,
I have a perfectly working environment and now I am trying to replicate the same in another server. I have a java stored procedure which invokes the Unix command using java Runtime.exec() in my code named "run". I am sure that the code is called and the java class run is resolved in oracle as I could see that in dba_java_resolvers dictionary. But I am not sure whether the function in java is called or whether a exception is thrown. how to identify this? Could there be any thing to do with settings in oracle side? please help me.
Thanks in advance,
MaruthaHi,
Do you get any output while running the code?
I'm testing similar solution and if there are any errors or Oracle can't execute the program due to permissions or other issues the error information will be displayed. Also in the Java class itself you need to catch exceptions and print stack trace to standard output.
declare
x number;
begin
dbms_output.enable(1000000);
dbms_java.set_output(1000000);
x:=system_command.run_command('testconnect.sh');
dbms_output.put_line('Returned value='||x);
exception
when others then dbms_output.put_line('Sql error='||substr(sqlerrm,1,250));
end;
<system_command.run_command> - replace with a call to your java stored procedure. -
Is it possible to use iFS API within java stored procedure?
question:
is it possible to use the iFS API for file handling
within a java stored procedure (which is invoced by a trigger)?
is there an "elegant" workaround if it is not possible?
problem:
my java code using the iFS API works fine outside
the java stored procedure
but invoked via trigger as java stored procedure
it throws following exception:
IFS-20102: Unable to start service (IfsDefault)
i am using:
oracle 9.0.1
oracle internet file system 9.0.1.1.0
windows 2000
thanksthanks for your help
i looked through the applications developers guide
the basics behind advanced queueing (as far as i understand) is:
program A inserts a message into the queue - and program B gets message from the queue and processes it
question 1:
but what is the difference between advanced queuing and a queue i create by myself
(simply with a database table) and let application B (which runs in a loop)
check if the queue is filled
or am i missing something important which makes advanced queuing more practicable for my problem?
question 2:
you wrote about advanced queuing support in iFS 9.0.3, but the newest version i found was iFS 9.0.2
did you reffer to the advanced queuing mechanism in general or to a spezial queuing feature in iFS 9.0.3?
thanks -
Problem with static vars of SQLJ java stored procedure
Hi,
When I'm calling a PL/SQL stored procedure that call a Java stored procedure from another Java stored procedure, the second call to the Java stored procedure does not see the first Java stored procedure static variables.
Why is that?
Can I configure it to work otherwise so all the Java stored procedure calls in this session will share the same static variables?
ThanksHi:
Remove your ; at the end of the sql string.
String sql = "SELECT VERSION_OFA FROM XX_PARAMETERS";
I don't know why JDev accept the ; at the end of string in a prepare statement but AFAIK its not legal.
If your are using the SQL pane of JDev may be the tool strip the ; for you.
Best regards, Marcelo. -
How to open external files in a Java stored procedure?
Hi y'all,
I'm trying to open an external text file from a Java stored procedure. The java sp has been successfully loaded, resolved, published, etc. in Oracle. I'm using the following statement to try to open the file (enclosed in a try/catch block):
BufferedReader fileObj = new BufferedReader(new FileReader("fileName.txt"));
I'm getting a file not found error. Where is Oracle looking (i.e., what directory)?
Your help is greatly appreciated,
Gary<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Gary Nool ([email protected]):
Hi y'all,
I'm trying to open an external text file from a Java stored procedure. The java sp has been successfully loaded, resolved, published, etc. in Oracle. I'm using the following statement to try to open the file (enclosed in a try/catch block):
BufferedReader fileObj = new BufferedReader(new FileReader("fileName.txt"));
I'm getting a file not found error. Where is Oracle looking (i.e., what directory)?
Your help is greatly appreciated,
Gary<HR></BLOCKQUOTE>
Hi Gary,
you must use a "database directory", e.g:
SQL>create directory WORKING_DIR as '/home2/common/';
SQL> select * from all_directories;
OWNER DIRECTORY_NAME
DIRECTORY_PATH
SYS WORKING_DIR
/home2/common/
Gert -
Java Stored Procedures and Triggers
I want to to use Java stored procedures and triggers within the Oracle 11g XE
So please , someone can help me because i tried but it didn't work
I don't know where is the problem
Thanks !!WRONG FORUM!
Welcome to the forum but this forum is for Java JDBC questions and issues. Your question should be posted in the SQL and PL/SQL forum
PL/SQL
>
I want to to use Java stored procedures and triggers within the Oracle 11g XE
So please , someone can help me because i tried but it didn't work
I don't know where is the problem
>
Mark this question ANSWERED and repost the question in the other forum
Before you post review the Oracle Database Java Developer's Guide - it shows how to create Java stored procedures and has example code
http://docs.oracle.com/cd/B28359_01/java.111/b31225/chfive.htm
And in the new post don't just say "I tried but it didn't work". You need to post the code that you tried and what you mean by "didn't work".
If you got any exceptions or errors you need to post a copy of the exact message or error that you are getting. -
No line numbers in stack trace from Java Stored Procedure exception
I have a Java Stored Procedure which can generate an exception. In one database (11.1.0.6) the Java stack trace contains line numbers for my code, but not for the classes loaded by default with the JVM. In another database (same version) the Java stack trace does NOT contain line numbers for my code, but does contain them for some of the classes loaded by default with the JVM!
Neither of the schemas where I am running the the Java stored procedure has a JAVA$OPTIONS tables as described here:
http://download.oracle.com/docs/cd/B28359_01/java.111/b31225/chtwo.htm#BABIGFGA
So the Java should have been compile "-debug" by default in both schemas. I specifically set the debug option to true using:
exec dbms_java.set_compiler_option('', 'debug', 'true');
but this had no effect.
Can anyone explain this behavior or tell me how to always get line number in the Java stack trace?Hi,
Try using java.util.logging package. Using these packages you can configure your logging information to include context down to the class name. Then each log message would be unique enough to know where it came from.
-Priyanka -
How to write call specs for a java stored procedure that takes a nested obj
Example Class :
public class B {
int number;
String str;
public class A {
private B[] _childern;
public B[] getChildern(){
return _children
public static void saveAll(A a) throws SQLException {
B[] children = a.getChildern();
for(int i=0; i<children.length; i++){
saveChild(children);
public static void saveChild(B ch)throws SQLException {
// do something
What would be the call specification for the method A.saveAll(A)? Your help will be apprecited.
Thank you
AjmalIn other words, How to pass a Java Object from a Java stored procedure to a Java client ???
Hello,
I don't know to deal with a Vector object that has been generated from a stored procedure.
Should I create first in the JDBC client and pass it as argument to the procedure ?
Thanks in advance. Here is an extract ...
On the client side :
<<
Vector buffer = new Vector();
CallableStatement call =
con.prepareCall ("{call my_procedure_run (?, ?)}");
call.registerOutParameter(2, java.sql.Types.JAVA_OBJECT );
call.setString (1, "bla bla bla");
call.setObject (2, buffer);
call.execute ();
buffer = (Vector)call.getObject (2);
>On the Java stored procedure
<<
public class my_procedure
public static void Run(String input_value, Vector buffer)
// ??? Vector buffer = new Vector();
try
while ( true )
buffer.addElement(...) ;
catch(Exception ex) { } -
Connecting to SQL Server and MYSQL from a Java stored procedure
hope someone can help with this. i'm trying to connect to different databases (My SQL, SQL Server) from a java stored procedure. when invoking from within an oracle 9i database, i get the java exception error -
"Cannot connect to MySQL server on 135.177.196.75:3306. Is there a MySQL server running on the machine/port you are trying to connect to?java.security.AccessControlException)".
this store procedure works fine when invoked from outside of oracle. any replies would be greatly appreciated. thanks!the correct drivers have been loaded. it works when called from outside of oracle. only when invoking from within oracle do we get the error message "Cannot connect to MySQL server on 135.177.196.75:3306. Is there a MySQL server running on the machine/port you are trying to connect to?(java.security.AccessControlException)". it sounds like a permissions/security/configuration issue - oracle is not allowing access to the machine/port for the MySQL or SQL Server database. appreciate the responses so far.
-
I want to use Java stored procedures .
My Java file is dependent on many imported files .
These dependent files are residing in middle layer .
I do not want to Place this dependent files into the database.
Can any one Please suggest me a method where i can make my Java code stored in database Running without storing this dependent files in the database.
Thanks.Nope. You will have to have the dependent classes also stored in the database. Without this, your java file won't get stored in DB.
--Shiv -
System Call via Java Stored Procedure?
Within a Java stored procedure I do
a FTP Call to a remote Server.
The running FTP Process belongs to
the Oracle System User (Operating System: Linux).
Is there a possibility to run that FTP
call with a different operating system
user?another example of invoking a Java Stored Prodedure from WITHIN a PL/SQL function? What's the issue here? A java stored procedure is a java class wrapped in PL/SQL. Consequently the invocation from with PL/SQL is a straightforward PL/SQL call.
So what is it that is troubling you?
Cheers, APC -
How to debug java stored procedures using jdwp with Eclipse IDE?
I need to debug the java stored procedures loaded in Oracle 9.2.0.6. The java files are loaded into the database using dbms_java.loadjava('-force -debug -verbose -resolve lib/java_stored_procs.jar'); The jar contains .java files and the database resolves and compiles them into .class files. Works fine but I need to debug the code. I am tried of the println method since takes too much and too many iterations.
My IDE is Eclipse 3.1. I want to use the jdwp for debugging in my IDE. Any one who knows the exact steps?
Thanks a lot.I need to debug the java stored procedures loaded in Oracle 9.2.0.6. The java files are loaded into the database using dbms_java.loadjava('-force -debug -verbose -resolve lib/java_stored_procs.jar'); The jar contains .java files and the database resolves and compiles them into .class files. Works fine but I need to debug the code. I am tried of the println method since takes too much and too many iterations.
My IDE is Eclipse 3.1. I want to use the jdwp for debugging in my IDE. Any one who knows the exact steps?
Thanks a lot. -
Error while deploying a Java Stored Procedure using JDeveloper
Hi,
I was going thru the Oracle By Example article: "Developing SQL and PL/SQL with JDeveloper". (http://www.oracle.com/technology/obe/obe9051jdev/ide1012/plsqlobe/obeplsql.htm)
One of the items in this article is - "Creating and Deploying a Java Stored Procedure"
I was able to create a java class, compile it. Created a deployment profile. created a pl/sql wrapper. While trying to deploy the java stored procedure, I am getting the following error:
Invoking loadjava on connection 'hr_conn' with arguments:
-order -resolve -thin
errors : class package1/mypackage/JavaStoredProc
ORA-29521: referenced name java/lang/StringBuilder could not be found
The following operations failed
class package1/mypackage/JavaStoredProc: resolution
oracle.aurora.server.tools.loadjava.ToolsException: Failures occurred during processing
at oracle.aurora.server.tools.loadjava.LoadJava.process(LoadJava.java:863)
at oracle.jdeveloper.deploy.tools.OracleLoadjava.deploy(OracleLoadjava.java:116)
at oracle.jdeveloper.deploy.tools.OracleLoadjava.deploy(OracleLoadjava.java:46)
at oracle.jdevimpl.deploy.OracleDeployer.deploy(OracleDeployer.java:97)
at oracle.jdevimpl.deploy.StoredProcHandler.doDeploy(StoredProcHandler.java:474)
at oracle.jdevimpl.deploy.StoredProcHandler.doDeploy(StoredProcHandler.java:361)
at oracle.jdevimpl.deploy.StoredProcHandler.doDeploy(StoredProcHandler.java:285)
at oracle.jdevimpl.deploy.StoredProcProfileDt$Action$1.run(StoredProcProfileDt.java:383)
#### Deployment incomplete. #### Oct 27, 2005 1:38:56 PM
Appreciate your help on this..I am using Jdeveloper 10.1.3 Early Access Version. JDK comes with it. I also have another JDK on my machine (JDK1.4.2_09)
-
ORA-04030: out of process memory when using Java Stored Procedures
Hello,
I have a problem using Java Stored Procedures in Oracle 10g.
My Java application performs http posts to a webservice and the response is parsed in order to populate some DB tables.
There is a scheduled job which calls the Java Stored Procedure every x minutes.
No matter of the 'x minutes' values - after about 160 - 200 calls I get this error:
ORA-04030: out of process memory when trying to allocate 1048620 bytes (joxp heap,f:OldSpace)
ORA-04030: out of process memory when trying to allocate 2097196 bytes (joxp heap,f:OldSpace)
The job stops just while is posting the http request. The weird thing is that almost each time the first http post request I get this error:
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:426)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(DashoA6275)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:140)
at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(SSLProtocolSocketFactory.java:130)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
and the second try works fine.
So, The out of process memory occured each time just before getting such an error, and I suspect to be a connection between these errors.
Tech details:
1. OS: WinXP
2. Oracle 10.1.0.2.0
3. To perform http post I use HttpClient 3.1 from Apache.
4. I checked the http connection to be closed each time, and this is done.
5. I checked the oracle statement and connection to be closed each time and this is done
6. The JVM error (logged in .trc files of Oracle) is:
java.lang.OutOfMemoryError
at java.lang.Thread.start(Native Method)
at sun.security.provider.SeedGenerator$ThreadedSeedGenerator.run(SeedGenerator.java:297)
DB Settings details:
Starting up ORACLE RDBMS Version: 10.1.0.2.0.
System parameters with non-default values:
processes = 200
sessions = 225
shared_pool_size = 159383552
large_pool_size = 8388608
java_pool_size = 104857600
nls_language = AMERICAN
control_files = C:\ORACLE\PRODUCT\10.1.0\ORADATA\XXXXXX\CONTROL01.CTL, C:\ORACLE\PRODUCT\10.1.0\ORADATA\XXXXXX\CONTROL02.CTL, C:\ORACLE\PRODUCT\10.1.0\ORADATA\XXXXXX\CONTROL03.CTL
db_block_size = 8192
db_cache_size = 29360128
compatible = 10.1.0
fal_client = XXXXXX
fal_server = XXXXXXs
log_buffer = 524288
log_checkpoint_interval = 100000
db_files = 70
db_file_multiblock_read_count= 32
db_recovery_file_dest = C:\oracle\product\10.1.0\flash_recovery_area
db_recovery_file_dest_size= 2147483648
standby_file_management = AUTO
undo_management = AUTO
undo_tablespace = undotbs_01
undo_retention = 14400
remote_login_passwordfile= EXCLUSIVE
db_domain =
dispatchers = (PROTOCOL=TCP) (SERVICE=XXXXXXXDB)
remote_dependencies_mode = SIGNATURE
job_queue_processes = 4
parallel_max_servers = 5
background_dump_dest = C:\ORACLE\PRODUCT\10.1.0\ADMIN\XXXXXX\BDUMP
user_dump_dest = C:\ORACLE\PRODUCT\10.1.0\ADMIN\XXXXXX\UDUMP
max_dump_file_size = 10240
core_dump_dest = C:\ORACLE\PRODUCT\10.1.0\ADMIN\XXXXXX\CDUMP
sort_area_size = 1048576
sort_area_retained_size = 1048576
db_name = XXXXXX
open_cursors = 500
optimizer_mode = FIRST_ROWS
pga_aggregate_target = 25165824
Any help would be appreciated. Thanks.
Can be a problem with JVM threading under Oracle ?The server prcess failed to allocate more memory for large objects ( in Oldspace).
If you Google ORA-04030, you will see several recommendations to work around this.
The Java VM in the database already has HttpClient, i don't know why you are loading the Apache HttpClient but this might not be the surce of the problem.
Kuassi http://db360.blogspot.com
Maybe you are looking for
-
Is there a device available to wirelessly transmit from a new MacBook Pro to a TV?
I want to wirelessly connect my MacBook Pro to my Sony TV
-
Photoshop Elements 2. Updating Adobe Online components from Adobe.com. Downloading File 1 of 2 No personal info. is being transmitted. File AWEX Files. txt When I try to open P.E.2 a window appears with the above message, showing a half loaded bar, c
-
Thumbnails in Project disappear every time
Most of the time I work with big projects, now for example a project wit 887 different shots. They were not recorded in the right order, so it is a lot of searching trough the project. That is not a problem when you have the thumbnails. But every tim
-
Verify user pin on a smart card & load a cap file on a card (with eclipse)
I have been able install JCWDE (Java card development Kit) successfully on eclipse.Basically all I need to do is verify user pin on a smart card.As in first set a pin and then verify it. To begin with I have referred many tutorials (here: http://www.
-
Printing email in thunderbird causes message to be deleted
when i open an email and print it, it disappears from the inbox. Server is imap and i'm running on a mac, 10.9