Java external procedure parameters
Hi, I'm calling a Java External Procedure like this:
CREATE FUNCTION HAS_GROUP (STRGROUP IN VARCHAR2)
RETURN VARCHAR2
AS LANGUAGE JAVA
NAME 'PKGPORTAL.GROUPS.HAS_GROUP
(java.lang.String) return java.lang.String';
The thing is that I need also to send it the CLIENT_IDENTIFIER, but I saw in every example that the parameters that the PLSQL function recieves are the same that you send to Java. Am I able to send an extra parameter to Java?. I need it to recieve the CLIENT_IDENTIFIER. Thank you.
I am using CREATE OR REPLACE JAVA CLASS,i missed that step in my first mail.
Is it possible that jdk version in oracle 9i is giving me poblem . Becoz for my java class i am using j2sdk1.4.2
I tried to deploy my class using Jdeveloper and i get this following error :
"ORA-29521: referenced name javax/crypto/NoSuchPaddingException could not be found"
I am importing javax.crypto in my class.
How i can update oracle java file to latest version?
Similar Messages
-
Java external procedure .....
Hi, i am calling my java function from oracle but i am getting this error :
'ora-29541 : class Eadmin.com/XX/MyClass could not be resolver'
where com.XX is package name for MyClass.
My java class code:
package com.XX;
public class MyClass {
public MyClass(){}
public static String EString(String strText, String strKey) {
/**CODE**/
return **SOME STRING**;
I did following steps to load JAVA function:
1) create or replace directory bfile_dir as 'e:\oracle9i\bin\com\XX'; /*my class files are in folder 'com\XX' */
2)create or replace function plsEString(varchar2,varchar2)
return varchar2 as language JAVA NAME 'com.XX.MyClass.EString(java.lang.String,java.lang.String) return java.lang.String';
3) declare
str varchar2(200);
begin
str:=plsEString('maviner','hi');
dbms_output.put_line('str: ' || str);
end;
ERRORS
ERROR at line 1:
ORA-29541: class EADMIN.com/XX/MyClass could not be resolved
ORA-06512: at "EADMIN.PLSESTRING", line 0
ORA-06512: at line 4
Where i am doing wrong?
thanxI am using CREATE OR REPLACE JAVA CLASS,i missed that step in my first mail.
Is it possible that jdk version in oracle 9i is giving me poblem . Becoz for my java class i am using j2sdk1.4.2
I tried to deploy my class using Jdeveloper and i get this following error :
"ORA-29521: referenced name javax/crypto/NoSuchPaddingException could not be found"
I am importing javax.crypto in my class.
How i can update oracle java file to latest version? -
Java stored procedure vs. PL-SQL vs. external java program
Hi,
I'm using a stored procedure for running a query and a few consequent updates. Currently I'm using Java stored procedure for that, which was my choice for simplicity on one hand, and running with the DB on the other.
In my tests, strangely enough it came out that running as java stored procedure was 3-4 times slower than running as a java program outside the database. I don't know how to explain this, and I wonder if switching to PL/SQL will improve the performance of the code.
Any experiences? recommendations?
Thanks,
DawgIn my tests, strangely enough it came out that running as java stored procedure was 3-4 times slower than running as a java program outside the database. I don't know how to explain this, and I wonder if switching to PL/SQL will improve the performance of the code.This isn't strange at all. See: Oracle's JVM (Aurora) is an independent Java Virtual Machine implementation, in accordance to specification. It implements all necessary parts of it (I think so). When you use an external JVM (I assume it's Sun's HotSpot JVM) you use completely different product. It is implemented in different way, it has many different code parts.
One of the biggest differences between Oracle's JVM and Sun's JVM is [Just-in-Time compiler|http://en.wikipedia.org/wiki/Just-in-time_compilation]. Oracle has implemented it only in the 11g version of database, i.e. 2 years ago, while Sun performed it back in 2000 and continues to improve it for the last 9 years. That would explain obvious differences between Java program inside and outside the DB: they are executed in absolutely different worlds. Diffs could be up to 10x times or more - that's not unusual.
If you are on 10g and want to compare performance of stored Java procedure vs external program, then you might use additional command-line instruction for external program to disable JIT:
-XintPS. I wouldn't use Java for your task - that's a total overkill. Use simple SP instead. -
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 -
Calling external servlet from java stored procedure
Hello,
I need to call an external servlet which is in 9iAS server ( unix box) from Java Stored procedure in oracle database.
Can anybody give me an idea? is it possible?
Thanks,
ViswaI am trying the same. Here is URL which will help u.
http://otn.oracle.com/sample_code/tech/java/jsp/samples/wsclient/Readme.html
Let me know when you run servlet successfully.
Regards
Satish -
Legal Java Stored Procedure method parameters
Hi,
I'm trying to establish whether Java arrays can be returned from Java Stored Procedures. It seems that I can only return single length (i.e. 1) arrays which is highly restrictive.
If I am creating a Java Stored Proc that will be called from pure Stored Proc land, and my JavaSP could raise a number of exceptions I'm avoiding this and instead trying to return an "error status" as a parameter that the caller can query. i.e. I want the "error status" to be an array of (3) strings including a severity, an error number, and a string containing the Java exception.
Is there a way to do this without requiring all my methods to have 3 String[] parameters, one for each part of the error status? Or is there a better way?
regards
--malcolmHi,
You could consider using object types to store your exception information. In that case you will have to use JPublisher to map the sql types to java types. JPublisher enables you to specify and customize the mapping of SQL object types, object reference types, and collection types (VARRAYs or nested tables) to Java classes.
For more info on JPublisher refer : http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96658/toc.htm
For some Java Stored Procedure samples using object types refer to http://otn.oracle.com/sample_code/tech/java/jsp/oracle9ijsp.html -
HELP!!! Problem of Calling external Web Service from a Java Stored Procedur
1.I read the topic on http://www.oracle.com/technology/sample_code/tech/java/jsp/samples/wsclient/Readme.html about Calling external Web Service from a Java Stored Procedur.
2.After I import .jar to Oracle what is required by the topic,som error occued.
Like: ORA-29521: javax/activation/ActivationDataFlavor class not found,
ORA-29545: badly formed class.
3.These is not enough .jar required on the topic? What can I do for ORA-29545: badly formed class?
Thany you!Try this
Re: HELP! Loading Java Classes into Oracle ERROR -
Problems calling external Web Service from a Java Stored Procedure
I'm using a sample code that I found here about calling external web services from a Java Store Procedure ( Credit Agency Web Service http://www.oracle.com/technology/sample_code/tech/java/jsp/samples/wsclient/Readme.html ) but when I run it ,send this error. I dont know what can I do or what is missing. Please help me. Thanks.
Error: Premature EOF encountered [java.io.EOFException] [SOAPException: faultCode=SOAP-ENV:IOException; msg=Premature EOF encountered; targetException=java.io.EOFException: Premature EOF encountered] at org.apache.soap.SOAPException.(SOAPException.java:77) at oracle.soap.transport.http.OracleSOAPHTTPConnection.send(OracleSOAPHTTPConnection.java:765) at org.apache.soap.rpc.Call.invoke(Call.java:261) at oracle.otnsamples.wsclient.CreditAgencyServiceStub.authorizeCustomer(CreditAgencyServiceStub.java:84) at Products.jspService(Products.jsp:120) at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:139) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:349) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:795) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:794) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112) at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192) at java.lang.Thread.run(Thread.java:534)I'm also facing problem in running the example on the page http://www.oracle.com/technology/sample_code/tech/java/jsp/samples/wsclient/Readme.html
I've Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 and Oracle Application Server 10g (10.1.3). When I executed the following command,
loadjava -thin -user sys/password@localhost:1521:oradb -resolve -synonym -verbose -grant public %OC4J_HOME%/webservices/lib/soap.jar %OC4J_HOME%/lib/dms.jar %OC4J_HOME%/jlib/javax-ssl-1_1.jar %ORACLE_HOME%/lib/servlet.jar %OC4J_HOME%/j2ee/home/lib/mail.jar
... mentioned in step 3 under the "Configuring the Application" section on the above link, the process terminates with the following error
The following operations failed
class oracle/net/www/protocol/https/Handler: resolution
class oracle/net/www/protocol/https/HttpsURLConnection: resolution
class oracle/soap/client/ProviderManagerClient: resolution
class oracle/soap/client/ServiceManagerClient: resolution
class oracle/soap/providers/JavaProvider: resolution
class oracle/soap/providers/ejbprov/EntityEJBProvider: resolution
class oracle/soap/providers/ejbprov/StatefulEJBProvider: resolution
class oracle/soap/providers/ejbprov/StatelessEJBProvider: resolution
class oracle/soap/providers/sp/SpProvider: resolution
class oracle/soap/server/http/SOAPServlet: resolution
class oracle/soap/transport/http/OracleSOAPHTTPConnection$1: resolution
class oracle/soap/transport/http/OracleSOAPHTTPConnection: resolution
class org/apache/soap/messaging/Message: resolution
class org/apache/soap/rpc/Call: resolution
class org/apache/soap/rpc/RPCMessage: resolution
class org/apache/soap/rpc/Response: resolution
class javax/net/DefaultServerSocketFactory: creation (createFailed)
class javax/net/DefaultSocketFactory: creation (createFailed)
class javax/net/ServerSocketFactory: creation (createFailed)
class javax/net/SocketFactory: creation (createFailed)
class javax/net/ssl/DefaultSSLServerSocketFactory: creation (createFailed)
class javax/net/ssl/DefaultSSLSocketFactory: creation (createFailed)
class javax/net/ssl/HandshakeCompletedEvent: creation (createFailed)
class javax/net/ssl/HandshakeCompletedListener: creation (createFailed)
class javax/net/ssl/SSLException: creation (createFailed)
class javax/net/ssl/SSLHandshakeException: creation (createFailed)
class javax/net/ssl/SSLKeyException: creation (createFailed)
class javax/net/ssl/SSLPeerUnverifiedException: creation (createFailed)
class javax/net/ssl/SSLProtocolException: creation (createFailed)
class javax/net/ssl/SSLServerSocket: creation (createFailed)
class javax/net/ssl/SSLServerSocketFactory: creation (createFailed)
class javax/net/ssl/SSLSession: creation (createFailed)
class javax/net/ssl/SSLSessionBindingEvent: creation (createFailed)
class javax/net/ssl/SSLSessionBindingListener: creation (createFailed)
class javax/net/ssl/SSLSessionContext: creation (createFailed)
class javax/net/ssl/SSLSocket: creation (createFailed)
class javax/net/ssl/SSLSocketFactory: creation (createFailed)
class javax/security/cert/Certificate: creation (createFailed)
class javax/security/cert/CertificateEncodingException: creation (createFailed)
class javax/security/cert/CertificateException: creation (createFailed)
class javax/security/cert/CertificateExpiredException: creation (createFailed)
class javax/security/cert/CertificateNotYetValidException: creation (createFailed)
class javax/security/cert/CertificateParsingException: creation (createFailed)
class javax/security/cert/X509Certificate: creation (createFailed)
exiting : Failures occurred during processing
I've checked the path to all the jar files.
I tried to run the command again with system/password instead sys/password but then I got the following stacktrace:
The following operations failed
class oracle/net/www/protocol/https/Handler: resolution
class oracle/net/www/protocol/https/HttpsURLConnection: resolution
class oracle/soap/client/ProviderManagerClient: resolution
class oracle/soap/client/ServiceManagerClient: resolution
class oracle/soap/providers/JavaProvider: resolution
class oracle/soap/providers/ejbprov/EntityEJBProvider: resolution
class oracle/soap/providers/ejbprov/StatefulEJBProvider: resolution
class oracle/soap/providers/ejbprov/StatelessEJBProvider: resolution
class oracle/soap/providers/sp/SpProvider: resolution
class oracle/soap/server/http/SOAPServlet: resolution
class oracle/soap/transport/http/OracleSOAPHTTPConnection$1: resolution
class oracle/soap/transport/http/OracleSOAPHTTPConnection: resolution
class org/apache/soap/messaging/Message: resolution
class org/apache/soap/rpc/Call: resolution
class org/apache/soap/rpc/RPCMessage: resolution
class org/apache/soap/rpc/Response: resolution
exiting : Failures occurred during processing
Thanks in advance for any useful help.
- -
JAVA vs. External Procedures
We are exporting blobs to files and have two methods to use. One is external procedures (see note:70110.1) and the other is a Java procedure (see Note:247546.1). Does anyone know which method is better from a performance standpoint.
Thanks.hello,
actually i can manage ETA without a varray, since there will b a maxximum of 3 -4 values of expected arrival times at each stop. this can b done with separate columns.
though i dont quite understand how lag() will help me...from what i understand lag() is to access values of previous rows. but in ETA table each element in the varray(if there is one) is going to be the expected arrival time of buses on a particular route at that particular stop, and is different from the arrival time at a previous stop(i.e.row).
but for my other table BUS_ROUTE i have 2 varrays describing the links and stops enroute. in quite a few procedures i have to loop through these arrays and perform some calculations in every iteration is varray the best way 2 go, or nested tables?
Thank you
Amina
As an aside, external procedures tend by their very
nature to be slow - there's an overhead incurred
each time we step outside the database. Therefore
you really ought to avoid using a C extproc unless
your calculations really cannot be done in PL/SQL or
a Java Stored Procedure.
Also, before you go down the VARRAY route you should
consider the virues of analytic functions, notably
[url=http://download-west.oracle.com/docs/cd/B1050
1_01/server.920/a96540/functions56a.htm#83619]LAG()[/u
rl]. I think you really ought to do some
benchmarking of parformance before you start afdding
denormalised columns like ETA. You may find the
overhead in maintaining those columns exceeds their
perceived benefits.
Cheers, APC -
Problem with external procedure
Please,
i'm doing some experiments in Microsoft Win2003 environment calling a c function as external procedures.
I've build a sample using Dev-C++ that make a DLL (i don't know c language) named sysDLL.dll
DllClass::DllClass(char *cmd)
int num;
num = system(cmd);
I need only to execute some OS command from PL/SQL (rdbms 10.2).
I've putted DLL in $ORACLE_HOME\bin.
Then I've created library with this statement :
Create Library scott.c_sysdll as 'C:\oracle\product\10.2.0\db_3\bin\sysdll.dll'
and at the end I've created the procedure :
create or replace procedure scott.shell(cmd IN varchar2)
as language C
library c_SysDll
name "DllClass"
parameters (cmd string);
But when I execute this procedure from sql*plus I've always get :
ORA-06521: PL/SQL: Error mapping function
ORA-06522: Unable to load symbol from DLL
ORA-06512: at "SCOTT.SHELL", line 1
ORA-06512: at line 1
Please help me, thanks !Suggest that you first make it much simpler. Do not object orientation. Use plain vanilla flavour C. And even before using C, use a kernel call instead. For example, the gethostname() is a standard Socket call that you will find on many operating system (including Windows & Unix).
The following code sample illustrates (can be run as is via SQL*Plus):<font color="blue">
-- specify the external library (shared lib on Unix, DLL on Windows)
create or replace library libc as 'libc.sl';
-- The kernel call that we're going to wrap with a PL/SQL function:
-- int gethostname(char *hostname, size_t size);
-- wrapping this API call with a PL/SQL function
create or replace function gethostname( hostname OUT string, size_t binary_integer ) return binary_integer is
external
library libc
name "gethostname"
language C
calling standard C
parameters
hostname STRING,
size_t INT
-- calling the kernel API routine from within PL/SQL
set serveroutput on
declare
host$ varchar2(60);
rc$ integer;
begin
rc$ := gethostname( host$, 60 );
dbms_output.put_line( 'hostname is ['|| host$ ||'] return code=['|| TO_CHAR(rc$) || ']' );
end;
/</font>
<p>
Of course, the DLL name for Window is different than the Shared Library ('libc.sl') used in the above snippet. Do not have a Win32 Oracle platform to test on, but you should find this API call in the winsock.dll library.
<p>
As for writing your custom extproc in C. Plain vanilla C is something as follows:
int dosomestuff()
return( 123456 );
<p>
Remember that this function has to be exported in the DLL interface.
<p>
Also keep in mind that using extproc is usually the last option to pursue when dealing with Oracle development. The basic rules are as follows:
1. Do it in SQL.
2. If it cannot be done in SQL, do it as a PL/SQL proc
3. If if cannot be done in PL/SQL. do it as a Java stored proc
4. If if cannot be done in Java, do is as an external proc<p>
The times that I need to resort to using Java is less than a handful (most obvious one is using Java to gain o/s command line access). I have never put external proc code into production as we have yet to have a need for something so exceptional, that it cannot be done using SQL, PL/SQL or Java as the last resort. -
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 -
Calling the Java Method in PL/SQL Java Stored procedure errors out
Hi,
I could not find a suitable thread to post my PL/SQL question so iam posting it here.........
I have written a java class by name XYZ which has a method ABC for which there are 9 arguements being passed and its a VOID method.
This java class has been loaded into ORACLE using DBMS_JAVA.LOADJAVA pkg, Now this class is being called in the oracle as a JAVA Stored procedure...... When ever im trying to call the procedure it throws the following error
ORA-29531: no method
*Cause: An attempt was made to execute a non-existent method in a
Java class.
*Action: Adjust the call or create the specified method.
The code snippet as follows
JAVA CODE:
Class xyz
public static void Abc (String hostName,
int port,
String serviceURL,
String soapAction,
int timeOut,
String wsUser,
String wsPasWd,
String keyStore,
String keyStorePasWd)
//method implementation
JAVA STORED PROCEDURE:
create OR REPLACE procedure ABC_JAVA_SP_CALL
(p_hostname in varchar2, p_port in number, p_serviceurl in varchar2, p_soapaction in varchar2, p_timeout in number, p_wsuser in varchar2, p_wspasswd in varchar2, p_ks_path in varchar2, p_ks_passwd in varchar2)
as
language java
name 'xyz.Abc(java.lang.String, int, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String)';
When i try to call
declare
p_hostname varchar2(100);
p_port number;
p_serviceurl varchar2(100);
p_soapaction varchar2(100);
p_timeout number;
p_wsuser varchar2(100);
p_wspasswd varchar2(100);
p_ks_path varchar2(100);
p_ks_passwd varchar2(100);
begin
//SP which returns the values for the required parameters.
comppkg.getvcsinfo(
p_hostname,
p_port ,
p_serviceurl,
p_soapaction,
p_timeout,
p_wsuser,
p_wspasswd,
p_ks_path,
p_ks_passwd
Layer7_icengc_ws_tes(p_hostname,
p_port ,
p_serviceurl,
p_soapaction,
p_timeout,
p_wsuser,
p_wspasswd,
p_ks_path,
p_ks_passwd);
end;
This thing ends up with
29531. 00000 - "no method %s in class %s"
*Cause: An attempt was made to execute a non-existent method in a
Java class.
*Action: Adjust the call or create the specified method.
Im not understanding what wrong am i doing
pls help
Edited by: madhusudan on Feb 12, 2013 8:07 PMHello,
there is the forum {forum:id=65} for questions about using Java within Oracle.
Regards
Marcus
Edited by: Marwim on 13.02.2013 07:56
I could not find a suitable thread to post my PL/SQL question so iam posting it here.........You got the hint to the correct forum alread in another thread {message:id=10837976}
And if you think this is not related to Java but PL/SQL, then you should ask in {forum:id=75} -
Executing batch file from Java stored procedure hang
Dears,
I'm using the following code to execute batch file from Java Stored procedure, which is working fine from Java IDE JDeveloper 10.1.3.4.
public static String runFile(String drive)
String result = "";
String content = "echo off\n" + "vol " + drive + ": | find /i \"Serial Number is\"";
try {
File directory = new File(drive + ":");
File file = File.createTempFile("bb1", ".bat", directory);
file.deleteOnExit();
FileWriter fw = new java.io.FileWriter(file);
fw.write(content);
fw.close();
// The next line is the command causing the problem
Process p = Runtime.getRuntime().exec("cmd.exe /c " + file.getPath());
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = input.readLine()) != null)
result += line;
input.close();
file.delete();
result = result.substring( result.lastIndexOf( ' ' )).trim();
} catch (Exception e) {
e.printStackTrace();
result = e.getClass().getName() + " : " + e.getMessage();
return result;
The above code is used in getting the volume of a drive on windows, something like "80EC-C230"
I gave the SYSTEM schema the required privilege to execute the code.
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
GRANT JAVAUSERPRIV TO SYSTEM;
I have used the following to load the class in Oracle 9ir2 DB:
loadjava -u [system/******@orcl|mailto:system/******@orcl] -v -resolve C:\Server\src\net\dev\Util.java
CREATE FUNCTION A1(drive IN VARCHAR2) RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'net.dev.Util.a1(java.lang.String) return java.lang.String';
variable serial1 varchar2(1000);
call A1( 'C' ) into :serial1;
The problem that it hangs when I execute the call to the function (I have indicated the line causing the problem in a comment in the code).
I have seen similar problems on other forums, but no solution posted
[http://oracle.ittoolbox.com/groups/technical-functional/oracle-jdeveloper-l/run-an-exe-file-using-oracle-database-trigger-1567662]
I have posted this in JDeveloper forum ([t-853821]) but suggested to post for forum in DB.
Can anyne help?Dear Peter,
You are totally right, I got this as mistake copy paste. I'm just having a Java utility for running external files outside Oracle DB, this is the method runFile()
I'm passing it the content of script and names of file to be created on the fly and executed then deleted, sorry for the mistake in creating caller function.
The main point, how I claim that the line in code where creating external process is the problem. I have tried the code with commenting this line and it was working ok, I made this to make sure of the permission required that I need to give to the schema passing security permission problems.
The function script is running perfect if I'm executing vbs script outside Oracle using something like "cscript //NoLogo aaa1.vbs", but when I use the command line the call just never returns to me "cmd.exe /c bb1.bat".
where content of bb1.bat as follows:
echo off
vol C: | find /i "Serial Number is"
The above batch file just get the serial number of hard drive assigned when windows formatted HD.
Same code runs outside Oracle just fine, but inside Oracle doesn't return if I exectued the following:
variable serial1 varchar2(1000);
call A1( 'C' ) into :serial1;
Never returns
Thanks for tracing teh issue to that details ;) hope you coul help. -
Database design and pl/sql vs external procedures
hi,
My project involves predicting arrival time of a bus at a bus-stop, given statistical data of traffic patterns on the previous n(say 3) days, as well as the current location of the bus(latitude-longitude).
Given current bus location, I derive my distance-until-destination bus-stop, which must be translated into time until arrival.
Ive enlisted the triggers and procedures involved in making the prediction. Thse procedures especially the determination of perpendicular distances involve some complex trigonometric operations. I would like to know if my approach is correct and my database design is suited for the operations to b performed.
Will it be more efficient to implement the procedures as external procedures or as pl/sql blocks
This is my database design:
LINKS ( a link is the road segment between adjacent bus-stops)
LINK_ID NUMBER [PRIMARY-KEY]
START_LATITUDE NUMBER
START_LONGITUDE NUMBER
START_STOP_ID NUMBER
END_LATITUDE NUMBER
END_LONGITUDE NUMBER
END_STOP_ID NUMBER
LINK_LENGTH NUMBER
BUS_ROUTE
ROUTE_ID NUMBER
LINKS_ENROUTE VARRAY(30) OF NUMBER
STOPS_ENROOUTE VARRAY(30) OF NUMBER
TRACK(keeps track of current location of bus)
BUS_ID NUMBER [PRIMARY-KEY]
ROUTE VARCHAR2(20)
LATITUDE NUMBER
LONGITUDE NUMBER
TS TIMESTAMP
LINK_ID NUMBER
START_STOP NUMBER
END_STOP NUMBER
ARRIVAL_TIMES(actual arrival times of the bus, updated by track)
BUS_ID NUMBER [PRIMARY-KEY]
BUS_ROUTE VARCHAR2(20)
ARRIVAL TIMESTAMP
STOP_ID NUMBER
ETA (expected time of arrival)
BUS_ID NUMBER
BUS_ROUTE VARCHAR2(20)
BUS_STOP_ID NUMBER
ARR_TIME VARRAY(5) OF TIMESTAMP
Triggers and procedures
1)TRACK_TRIGGER
On insert/update of track determine which link the us is currently on.
Invoke a procedure that calculates perpendicular distance from current location to all links en-route (cursor on LINKS).
Results are stored in a temporary table. Select the link-id of the tuple whose perpendicular distance is MINIMUM. This is the link the bus is currently on. Place link-id, start_stop_id and end_stop_id in corresponding row of TRACK.
2)ARRIVAL_TRIGGER
update ARRIVAL_TIMES.and store in ARRIVAL_TIMES that start-stop id with the time-stamp of the current track record.
b)update ETA: Find the BUS-STOPS that come before the START_STOP of current track record. All these rows are deleted from the ETA tables, as the bus has already crossed these stops.
3)Prediction Algorithm Procedure.
Determine distance until destination for each STOP, 20 stops down from stop current location.
Determine current avg. speed of the bus over a 2 hour window, by dividing total distance traveled by time taken.
Calculate time-until arrival T1=current avg. speed * distance until destination
From the records of previous n days (say n=3) find those buses on the same route that were near the link the bus is currently on. Again determine avg speed over 2 hour window and calculate avg. speed.
Calculate travel time T(i) = speed*distance until destination. i.=2,3, 4
The final predicted arrival time is a weighted sum of all T(i).
I hope Im not asking for too much, but the help would be greatly appreciated.
Thankyou,
Aminahello,
actually i can manage ETA without a varray, since there will b a maxximum of 3 -4 values of expected arrival times at each stop. this can b done with separate columns.
though i dont quite understand how lag() will help me...from what i understand lag() is to access values of previous rows. but in ETA table each element in the varray(if there is one) is going to be the expected arrival time of buses on a particular route at that particular stop, and is different from the arrival time at a previous stop(i.e.row).
but for my other table BUS_ROUTE i have 2 varrays describing the links and stops enroute. in quite a few procedures i have to loop through these arrays and perform some calculations in every iteration is varray the best way 2 go, or nested tables?
Thank you
Amina
As an aside, external procedures tend by their very
nature to be slow - there's an overhead incurred
each time we step outside the database. Therefore
you really ought to avoid using a C extproc unless
your calculations really cannot be done in PL/SQL or
a Java Stored Procedure.
Also, before you go down the VARRAY route you should
consider the virues of analytic functions, notably
[url=http://download-west.oracle.com/docs/cd/B1050
1_01/server.920/a96540/functions56a.htm#83619]LAG()[/u
rl]. I think you really ought to do some
benchmarking of parformance before you start afdding
denormalised columns like ETA. You may find the
overhead in maintaining those columns exceeds their
perceived benefits.
Cheers, APC -
[b]Java Stored Procedure generating ora-932 in Oracle 9i [/b]
Hi ,
I have written a Java Stored procedure. And I have written a wrapper function as bellow
FUNCTION "GENERATE_AC_EXCEL_REPORT_FN"
( refCursorCall VARCHAR2, fromDate Date, ToDate Date,
nsn VARCHAR2, period varchar2, site VARCHAR2,
vendor VARCHAR2, spotbuyType VARCHAR2, dataType, VARCHAR2 )
return number
as LANGUAGE java
NAME 'accountingExcelReports.excelPrinter( java.lang.String, java.sql.Date, java.sql.Date, java.lang.String,java.lang.String , java.lang.String,
java.lang.String, java.lang.String , java.lang.String) return int';
This function returns 1000 upon successful execution.
This used to execute fine in Oracle 8.1.7.
We installed Oracle 9i recently.
Server version is 9.2.0.2.1.
Jserver version is 9.2.0.2.0 .
Now The function call works fine for the first time. And When execute it for sencond time in the same Session,
The program is erring out saying inconsistent data typpes.
This is happening during passing parameters.
SQL> select
2 generate_ac_EXCEL_report_fn('Period', to_date('7-1-2002','MM-DD-YYYY'),
3 to_date('7-31-2002','MM-DD-YYYY'), NULL,
4 NULL, NULL, NULL, 'ALL' ,'SPOTBUY') from dual;
GENERATE_AC_EXCEL_REPORT_FN('PERIOD',TO_DATE('7-1-2002','MM-DD-YYYY'),TO_DATE('7-31-2002','MM-DD-YYY
1000
SQL> select
2 generate_ac_EXCEL_report_fn('Period', to_date('7-1-2002','MM-DD-YYYY'),
3 to_date('7-31-2002','MM-DD-YYYY'), NULL,
4 NULL, NULL, NULL, 'ALL' ,'SPOTBUY') from dual;
select
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected IN Conversion failed
And upon further testing, i noticed this happens when the dates are passed. If date parameters are nulled out, Then the program executes perfectly any number of times.
The same program worked fine in Oracle 8.1.6
Any ideas?
Please help.
Thanks,
SrinivasHi Srinivas,
you shouldn't be calling conn.close() and its not needed when using Server Side Internal driver. If you are calling conn.close, then .....
extract from JDBC user guide
If you do call the close() method, be aware of the following:
All connection instances obtained through the defaultConnection() method, which actually all reference the same connection object, will be closed and
unavailable for further use, with state and resource cleanup as appropriate. Executing defaultConnection() afterward would result in a new connection
object.
Even though the connection object is closed, the implicit connection to the database will not be closed.
http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/advanc.htm#1001042
Elango.
Maybe you are looking for
-
Random shuffle no longer works
I have itunes installed on my pc. Random shuffle feature no longer works. Latest version on itunes is installed.
-
Hi, I have problem, I want to convert the data coming from the XML document in base64Binary format to byte[] format. could you please give me some pointers to achieve this ? Thanks & Regards, Guru
-
Why after two new updates can I know longer watch or download movies?
This morning firefox updater advised me that two new addons would be installed as soon as I restarted Firefox, which I did straight away. When I opened up a webpage and clicked on a movie to watch everything froze. I couldn't open any other tabs eith
-
Packing - Two different material are packed toghether on same box
Hi Gurus, I bring problem during automatically packing on delivery creation Both material are packed toghether on same box ( I don't want it ) Both material are on same packing instruction for box Both material have target / minimun and rounding qty
-
HI ALL, I HAVE BEEN WRITING CODE FOR A TEST RMI 'GRAPHICSERVER'. THIS IS A KIND OF A SERVER THAT PROVIDES CLIENTS WITH A FRAME. ON WHICH IT DRAWS DIFFERENT SORT OF SHAPES ON CLIENT REQUEST e.g. CLIENT CAN REQUEST FOR A LINE OR AN OVAL etc. INITIALLY