Java, Stored Procedure/Function,  JSP

Hello All,
Is there any one who can help.
I would like to return a record set from a stored function and display the results with a JSP program.
The same function is currently being used to retrieve data for a related process, but that process uses a procedure to call the function and the results are written to a database table. This works fine.
This time I would like to create a record set and display the results on screen, but I am having problems.
ResultSet rsTimecard = null;
Connection conn = sqlMgr.getConnection();
CallableStatement cs = conn.prepareCall("{ ? = call TA_WEBDBA_HOURS_USE_PKG.aftimecard_jocas_records(to_date('01-OCT-2004', 'DD-MON-YYYY'), to_date('30-OCT-2004', 'DD-MON-YYYY')) }");
cs.registerOutParameter(1, Types.OTHER); // This is line 99. Types.OTHER is the Invalid column type that the system is complaining about.
cs.execute();
rsTimecard = (ResultSet) cs.getObject(1);
<table width="100%">
<%
while(rsTimecard.next())
%>
<tr>
<td colspan="1" width="10%"> 
</td>
<td colspan="1" width="10%">
<%=rsTimecard.getString(1)%>
</td>
I get:
Application Error
The following error occurred: Invalid column type
java.sql.SQLException: Invalid column type
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:189)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:231)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:294)
at oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:5992)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterBytes(OracleCallableStatement.java:250)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:389)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:446)
at com.evermind.sql.FilterCallableStatement.registerOutParameter(FilterCallableStatement.java:373)
at aftimecard.jsp._PSRptView._jspService(PSRptView.jsp:99)
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:778)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
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:186)
at java.lang.Thread.run(Thread.java:534)

Rufus,
Have you seen the Refcursor Sample? I believe it will help you.
http://tinyurl.com/5r6hm
Good Luck,
Avi.

Similar Messages

  • Is is possible to create Socket using Java Stored Procedures/Function(Ora)?

    Hello Friends,
    Is is possible to create Socket using Java Stored Procedures/Function in Oracle?
    OR
    How I can send a message from oracle to Java Desktop Application which is working like server program?
    Please Guide !!

    J3Ganesh wrote:
    Hello Friends,
    Is is possible to create Socket using Java Stored Procedures/Function in Oracle?No, Oracle was very careful to take that feature out of the JDK provided in Oracle 10/11, but you can buy that feature back for, if I remember correctly, about 5000 dollars. (I actually raised a service request on this and then told my rep what I thought about the answer I received--some thing along the line of money grubbing so and so....)
    How I can send a message from oracle to Java Desktop Application which is working like server program?You can make a table and poll it from time to time from the Java side and write and commit what ever you want to the table. I do not know any way to send a signal from Oracle DB an external Java application--Java or PL/SQL stored procedure.

  • Java Stored Procedure functions in SQL DML - multiple invocations

    When running a java stored procedure as part of a DML statement the procedure is invoked 10-15 times for each row that is updated.
    For example:
    Update mytable set mycolumn = myjsp(somecolumn);
    I undertand that this was a known bug with the JDBC driver. Has it been fixed? Is there a workaround?
    We are using 8.1.6 on NT 4
    Thanks
    Julian

    Hello ,
    I tried here, and it seems to call the function once for each row
    eg :
    package package90;
    public class Class1 extends Object {
    public int get_data(int i)
    return i+10;
    Published the get_data function as
    myproject67.get_data
    SQL> connect scott/tiger@orcl8i
    Connected.
    SQL> set serveroutput on
    SQL> exec dbms_java.set_output(5000);
    PL/SQL procedure successfully completed.
    SQL> select * from test_java;
    NO1
    10
    10
    SQL> insert into test_java values (20);
    1 row created.
    SQL> select * from test_java;
    NO1
    10
    10
    20
    SQL> update test_java set no1=myproject67.get_data(no1);
    Called
    Called
    Called
    3 rows updated.
    SQL> select * from test_java;
    NO1
    20
    20
    30
    SQL>

  • Unable to access Custom UDTs returned from a Java Stored Procedure

    Hi,
    I have a UDT in the DB :-
    create type contactrecord as object (
    CN_ID NUMBER(8),
    CN_TITLE VARCHAR2(40),
    CN_FIRST_NAME VARCHAR2(25)
    and this is the corresponding java class ContactDetails.java that maps to this UDT, that I loaded in the Aurora VM.
    package package1;
    mport java.sql.SQLData;
    import java.sql.SQLException;
    import java.sql.SQLInput;
    import java.sql.SQLOutput;
    public class ContactDetails implements SQLData
    private String sql_type;
    private long CN_ID;
    private String CN_TITLE;
    private String CN_FIRST_NAME;
    public String getSQLTypeName() throws SQLException
    return this.sql_type;
    //implementation of readSql
    public void readSQL(SQLInput stream, String typeName) throws SQLException
    sql_type = typeName;
    CN_ID = stream.readLong();
    CN_TITLE = stream.readString();
    CN_FIRST_NAME = stream.readString();
    public void writeSQL(SQLOutput stream) throws SQLException
    stream.writeLong(CN_ID);
    stream.writeString(CN_TITLE);
    stream.writeString(CN_FIRST_NAME);
    //getters and setters for the class vars go here.....
    There is another class A.java that has a java stored procedure/function, which I loaded into the Aurora VM
    Here is the class.
    package package1;
    public class A
    public static ContactDetails returnObject(String name )
         ContactDetails cd = new ContactDetails();
         cd.setCN_ID(1);
    cd.setCN_FIRST_NAME(name);
    return cd;
    Then I declared the call spec for A.returnObject() as
    FUNCTION returnObject(name varchar2) return contactrecord
    AS LANGUAGE JAVA
    NAME 'package1.A.returnObject(java.lang.String) return package1.ContactDetails';
    Then I tried to call the function returnObject through JDBC calls from a class in another VM.
    When I access the object returned by the function, I get a null object.
    Here is the Client code:
    CallableStatement cs = null;
    ResultSet rs = null;
    try
    cs = conn.prepareCall("{ ? = call returnObject(?) }");
    java.util.Map map = conn.getTypeMap();
    map.put("ADMIN.CONTACTRECORD", Class.forName("package1.ContactDetails"));
    conn.setTypeMap(map);
    cs.registerOutParameter(1, OracleTypes.STRUCT, "ADMIN.CONTACTRECORD");
    cs.setString(2, "John Doe" );
    cs.execute();
    ContactDetails cd = (ContactDetails)cs.getObject(1);
    System.out.println("contact first name is:-"+cd.getCN_FIRST_NAME()); //Null Pointer here..cd is null....:(
    if (cs != null) cs.close();
    catch(Exception e)
    e.printStackTrace();
    Although If I try to access the same function from a pl/sql block, I am able
    to access the contactrecord fields.
    What could be wrong ..???
    I could not find any error with the object mapping, as it works perfectly when I interact directly from my VM to the DB,
    without going thru the aurora VM.
    I am using a OCI driver to connect to the DB via JDBC.
    Thanx in advance for any help at all.
    -sk

    Shahid,
    I too have had bad luck in many cases with the automatic translation of Java types to PL/SQL and back. I think the SYS package on the PL/SQL side which handles some of the conversion is DBMS_PICKLER (there are equivalent Java classes which do the same in that world and seem to execute automagically when a conversion is needed). You might want to double-check the data type mappings against the DOC on OTN to make sure they map 1-1. Also make sure the permissions are granted against your objects to whoever is executing them, etc. Very often, I've resorted to passing simple scalar types between the two languages as in some cases the results with complex types are inconsistent.
    Sorry this isn't much help,
    -Dan
    http://www.compuware.com/products/devpartner/db/oracle_debug.htm
    Debug PL/SQL and Java in the Oracle Database

  • Return national language strings from java stored procedures

    Hi, all.
    How does i can return String which contains national characters from java stored procedure? I.e. convert UTF java string to national language of database. It's does not processing automatically (why?).
    declaration of procedure:
    CREATE OR REPLACE FUNCTION TestNLSString RETURN VARCHAR2
    AS
    LANGUAGE JAVA
    NAME 'test.SomeClass.getNLSString() return java.lang.String';
    SELECT TestNLSString AS X FROM DUAL;
    X
    iiiii
    OS: Windows 2000 Server
    Oracle Server version: Oracle 8.1.7.1.4

    Ok. I had a specific problem.
    I want to use java stored procedure (function) to make a connection to remote db using supplied connection parameters make some quieries there end return results in a form of structured data - object.
    I have defined an object type in a database where the function will reside. I granted execute privilege to public user on this type, made public synonyms to both, the object type and the function, so anybody connected to the same database would have an access to this functionality.
    I supposed that if I supply connection parameters for some other user but the same database when running the function, everything should go smooth. Yeah.
    My java code executed ok: it made a connection to the db with some x user, it resolved object type descriptor given (oracle.sql.StructDescriptor), but pl/sql wrapper function reported the error I've mentioned. If I executed the function giving it the connection parameters for same account as where object type was declared, everything went fine.
    My final solution is:
    Make TWO! connection in java code: 1st for ("jdbc:default:connection:"), 2nd for remote database account.
    Use first connection to construct oracle.sql.StructDescriptor
    Use second connection to retreive data from remote db

  • Publishing JSP form JAVA stored procedure [Oracle8i 8.1.7]

    Hi folks,
    I wonder if anybody knows a way to publish JSP from JAVA stored procedure.
    I know there is a way to load java class using PL/SQL package DBMS_JAVA.loadjava(), or
    oracle.aurora.server.tools.loadjava.LoadJavaMain.serverMain() from java.
    But I need somthing like publishjsp to translate the JSP.
    Also would be nice if I can invoke this from a LOB where I have stored my JSP.
    Any ideas?
    Mitko

    I case anyone is interested.
    I managed to find out what I was doing wrong.
    First when you call a stored procedure that is in a package and is a method of a class. You call it referencing the packagename.method. Leaving out the class name. Also, since this was a method that returns a value. The return value has to be assigned to a variable or used in an sql statement. Such as:
    var x number;
    call claimsprocedures.ip(19990033) into :x;call completed
    print x;(then the value is displayed in sql*plus
    scirco.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by scirco:
    I created a simple java stored procedure and depoloyed it using the deployment wizard. The code for the class is as follows:
    // Copyright (c) 2000 CAP-MPT
    package ClaimsProcedures;
    import sqlj.runtime.*;
    import sqlj.runtime.ref.*;
    import java.sql.*;
    import java.sql.SQLException;
    * A Sqlj class.
    * <P>
    * @author Sebastian Circo
    public class ClaimsFinancialHistory extends Object {
    * Constructor
    public ClaimsFinancialHistory() {
    public static int IP(int Claimno) throws SQLException {
    int Val;
    Val = 0;
    #sql {select sum(amount) into :Val from reshist
    where claimno = :Claimno and type = 'RI'};
    return Val;
    The wizard indicated that everything deployed properly. However when I try to call the procedure/method "IP" from sql*plus I get the following message: ORA-06576: not a valid function or procedure name. I double checked to make sure that I'm publishing the "IP" method and I still get the same error. I also tried calling the procedure with the schema.class.procedure form, still same error.
    Can anyone help?
    thanks
    scirco<HR></BLOCKQUOTE>
    null

  • How to execute a procedure or function from Java Stored procedure

    Hi,
    I am new to Java Stored Procedures. I am working on Oracle 8i and JVM 1.3.1. I want to call a PL/SQL procedure from within Java. I have tried looking at severa; cources but they are quite high level for me. Can someone provide a simple example including the Source Code for .java file and also the calling function's code?
    Heres a sample of what I have been working on: I an including Java code, and Function code and how I call the function. Instead of doing "select sysdate from dual" I want to do like "create table temp1(var1 varchar2(10))" or similar... like "exec procname(var1)" etc.
    Thanks in advance.
    PS. The variable passed in function is just a dummy variable.
    -----Begin Java code-------
    import java.sql.SQLException;
    import java.sql.PreparedStatement;
    import java.sql.Statement;
    import java.sql.Connection;
    import java.sql.ResultSet;
    //Oracle Extensions to JDBC
    import oracle.jdbc.driver.OracleDriver;
    public class Test2{
    public static String Testing(String d) {
    Connection connection = null; // Database connection object
    try {
    // Get a Default Database Connection using Server Side JDBC Driver.
    // Note : This class will be loaded on the Database Server and hence use a
    // Se[i]Long postings are being truncated to ~1 kB at this time.

    what your after is
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:oci:@<hoststring>", "scott", "tiger");
    CallableStatement cs = conn.prepareCall ("begin ? := foo(?); end;");
    cs.registerOutParameter(1,Types.CHAR);
    cs.setString(2, "aa");
    cs.executeUpdate();
    String result = cs.getString(1);
    a more complete description can be found in the documentation at
    http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/basic.htm#1001934
    Dom

  • CLASSPATH configuration for jsp (java stored procedures)

    Hi.
    I have a very simple question for you people.
    I don't know where to set up the CLASSPATH configuration on a HP-UX so that Aurora can see this include jar file and my java stored procedure can run correctly.
    Thanks a lot.
    Flavio Matiello

    The way global variables could be created using java classes is by using static variables.The class variable values are stored in the JVM's memory
    In Oracle8i Each session gets its own JVM & hence you cannot have a Java class variable which could
    span across sessions.
    Hope this helps

  • Calling XML API's from Java Stored Procedures in DB

    Hi,
    I am have and Oracle 10gR2 db installed and XML Publisher Enterprise Server 5.6.2.
    I have created the following Java Class and used loadjava to make it a Java Stored Procedure:
    <code>
    import java.io.IOException;
    import java.lang.Object;
    import oracle.apps.xdo.XDOException;
    import oracle.apps.xdo.template.FOProcessor;
    import oracle.apps.xdo.template.RTFProcessor;
    public class callingXMLP{
    public static String rtfToXsl(String rtfFile, String xslFile)
    try {
    RTFProcessor rtfProcessor = new RTFProcessor(rtfFile); //Input RTF
    rtfProcessor.setOutput(xslFile);
    rtfProcessor.process();
    } catch (IOException IOE) {
    return" Error "+IOE.getMessage();}
    catch(XDOException XDE ){
    return" Error "+XDE.getMessage();
    return "Success";
    public static String mergeXmlXsl(String xmlFile, String xslFile, String outputFile)
    FOProcessor processor = new FOProcessor();
    processor.setData(xmlFile); //Input XML File
    processor.setTemplate(xslFile); //Input XSL File
    processor.setOutput(outputFile); //Ouput File
    processor.setOutputFormat(FOProcessor.FORMAT_PDF);
    //start processing
    try {
    processor.generate();
    catch (XDOException e){
    e.printStackTrace();
    //System.exit(1);
    return "Error - "+e.getMessage();
    //System.exit(0);
    return "Success";
    </code>
    I then wrap this using the following function spec in pl/sql:
    create or replace function callXMLP(input1 VARCHAR2, output1 VARCHAR2) RETURN VARCHAR2
    as language java name 'callingXMLP.rtfToXsl(java.lang.String,java.lang.String) return java.lang.String';
    and
    create or replace function mergeXMLXSL(xml VARCHAR2, xsl VARCHAR2, output VARCHAR2) RETURN VARCHAR2
    as language java name 'callingXMLP.mergeXmlXsl(java.lang.String,java.lang.String,java.lang.String) return java.lang.String';
    Calling the callXMLP function works fine, and produces an XSL file from the input RTF file as expected.
    When I run the mergeXMLXSL function, it says that the function has completed successfully, but it seems to be throwing an XDOException error as it is returning "Error - null" message from the Java.
    A PDF document is being created, but it does not have any content. I have also modified the Java to create an RTF instead, but still the same thing happens.
    Is there anything that I need to check, or something that I am missing when trying to create the final PDF document?
    Please help, I am completely stuck with this now.
    Many Thanks,
    Cj

    Hello Chris,
    I have been able to create a PDF from the database. I loaded the following jar files and removed any java class that could not compile.
    activation.jar, axis-ant.jar, axis.jar, axis-schema.jar, bicmn.jar, bipres.jar, collections.jar,
    commons-beanutils.jar, commons-collections-3.1.jar, commons-collections.jar, commons-dbcp-1.1.jar commons-digester.jar, commons-discovery.jar, commons-el.jar, commons-fileupload.jar, commons-logging-api.jar commons-logging.jar, commons-pool-1.1.jar, http_client.jar, i18nAPI_v3.jar, javamail.jar, jaxrpc.jar,
    jewt4.jar, jsp-el-api.jar, log4j-1.2.8.jar, logkit-1.2.jar, ojpse.jar, oracle-el.jar, oraclepki.jar,
    orai18n.jar, quartz-1.5.1.jar, quartz-oracle-1.5.1.jar, regexp.jar, saaj.jar, service-gateway.jar, share.jar, uix2.jar, uix2tags.jar, versioninfo.jar, wsdl4j.jar, xdocore.jar, xdoparser.jar, xdo-server-delivery-1.0-SNAPSHOT.jar, xdo-server-kernel-0.1.jar, xdo-server-kernel-impl-0.1.jar, xdo-server-scheduling-1.0-SNAPSHOT.jar, xercesImpl.jar, xmlparserv2-904.jar, xmlpserver.jar, xsu12.jar
    I needed to copy the XML Publisher fonts to the database server and ran the following java grants, note my $ORACLE_HOME is /opt/app/oracle/product/10.1.0/
    dbms_java.grant_permission('XMLP', 'java.util.PropertyPermission', '*', 'read,write');
    dbms_java.grant_permission('XMLP', 'java.net.SocketPermission', '*', 'connect, resolve');
    dbms_java.grant_permission('XMLP', 'java.io.FilePermission', '/tmp/*', 'read, write, delete');
    dbms_java.grant_permission('XMLP', 'java.io.FilePermission', '/opt/app/oracle/product/10.1.0/javavm/lib/*', 'read');
    dbms_java.grant_permission('XMLP', 'java.io.FilePermission', '/opt/app/oracle/product/10.1.0/javavm/lib/fonts/*', 'read');
    dbms_java.grant_permission('XMLP', 'java.lang.RuntimePermission', 'setFactory', '');
    George

  • Java Stored Procedures and Sockets

    We need to synchronize data real time b/w Oracle and the legacy HP3000 system.
    For sending data from Oracle to HP3000 we are thinking of using Sockets.
    We dont know whether a socket connection can be established from the Oracle database level or need to be from the OS level(here Linux)
    I heard that Java stored procedures(JSP) can establish socket connection.
    Can someone provide me pointers regarding
    (a) setting up socket connection from the database
    (b) possibility of transferring data via sockets and using jdbc, and how to send data efficiently and if it is wise
    Thanks,
    Vinoj

    I don't have much experience with Lite, but I'm running 9i Personal Edition. Any information about triggers can be found in the "ALL_TRIGGERS" view. You will want to filter out any rows where OWNER = 'SYS' unless you created your triggers as SYS. As for procedures and functions, you can see what you have created in the "ALL_OBJECTS" view where OBJECT_TYPE = 'PROCEDURE' or 'FUNCTION', once again filtering out rows where OWNER = 'SYS'. To see the code of any procedure or function, select substr(text,1,80) from ALL_SOURCE where NAME = 'function name' ORDER BY LINE.
    Hope this helps!

  • Broken Java Stored Procedure Demo

    The link to download HotelBookingsSample.jar does not work. It is located on http://otn.oracle.com/sample_code/tech/java/jsp/samples/jsptrigger/Readme.html

    Do as follows:
    Define a JDBC Connection to your DB - use this name only.
    Create a Deployment profile (Java Stored Procedure )(with [x]Publish option) to the same connection.
    Then in the deployment tab of the Message View (View | Message View), you will see the deployment.
    Then you can call your procedures, functions using SQL*Plus by
    Expand Connection Folder
    Right Click on the JDBC Connection
    Select Invoke SQL*Plus...
    This will invoke SQL*Plus with the info from this connection.
    In SQL*Plus enter various statements to invoke your Java Stored Procedure.
    For grins, try:
    In JDeveloper, select
    File | New ... Class / JavaStoredProcedure
    Add the following methods to the bottom:
    =============
    public static String getJDBTime( ) {
    return (new Date()).toString();
    private static int nSeq = 0;
    public static int getNextSequence( ) {
    return nSeq++;
    ===========
    Then Create a deployment profile and deploy it.
    Then Invoke SQL*Plus and call it as:
    select <PackageName>.FunctionName() from dual;
    In my case, my SQL*Plus window looked as:
    SQL>
    SQL>
    SQL> select MYPROJECT5.GETJDBTIME() from dual;
    MYPROJECT5.GETJDBTIME()
    Wed Dec 20 16:12:16 CST 2000
    SQL> select MYPROJECT5.GETJDBTIME() from dual;
    MYPROJECT5.GETJDBTIME()
    Wed Dec 20 16:12:22 CST 2000
    SQL> select MYPROJECT5.GETNEXTSEQUENCE() from dual;
    MYPROJECT5.GETNEXTSEQUENCE()
    0
    SQL> select MYPROJECT5.GETNEXTSEQUENCE() from dual;
    MYPROJECT5.GETNEXTSEQUENCE()
    1
    SQL> select MYPROJECT5.GETNEXTSEQUENCE() from dual;
    MYPROJECT5.GETNEXTSEQUENCE()
    2
    SQL>
    I hope this helps,
    -John
    null

  • 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', '&lt;&lt;ALL FILES&gt;&gt;', '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.

  • [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&gt; 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&gt; 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,
    Srinivas

    Hi 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.

  • While executing java stored procedure i got an error

    I have used this command to load java source into data base
    loadjava -user ENCORA/ENCORA C:\framework\Packages\testdevelopement\HOST.java
    but while executing i got an error.
    SQL> create or replace function run_cmd(p_cmd in varchar2) return number
    2 as
    3 language java
    4 name 'HOST.RunThis(java.lang.String[]) return integer';
    5 /
    Function created.
    SQL> create or replace procedure RC(p_cmd in varchar2)
    2 as
    3 x number;
    4 begin
    5 x := run_cmd(p_cmd);
    6 end;
    7 /
    Procedure created.
    SQL> set serveroutput on size 1000000
    SQL> exec dbms_java.set_output(1000000)
    PL/SQL procedure successfully completed.
    SQL> exec rc('/usr/bin/ps -ef');
    BEGIN rc('/usr/bin/ps -ef'); END;
    ERROR at line 1:
    ORA-29540: class HOST does not exist
    ORA-06512: at "ENCORA.RUN_CMD", line 0
    ORA-06512: at "ENCORA.RC", line 5
    ORA-06512: at line 1
    can any one suggest me how can i resolve this problem?

    Hi Uday,
    My guess is that there is a problem with your java stored procedure that is causing the "ExceptionInInitializer" error to be thrown. According to the javadoc:
    is thrown to indicate that an exception occurred during
    evaluation of a static initializer or
    the initializer for a static variable
    Since I didn't see any of your code in your post, I can't help you much more, I'm afraid. Perhaps if you would provide some more details, I may be able to help you some more. I think the following details would be helpful:
    1. Complete error message and stack trace you are getting.
    2. The section of your java code that you think is causing the problem.
    3. Oracle database version you are using.
    Good Luck,
    Avi.

  • 21700 while calling java stored procedure in 9i

    I create a java stored procedure that takes a varray of a rowtype. When I call that procedure, I get an ora-21700. If I remove the varray from the parameter list, I can call the procedure okay. My goal is to create a generic java procedure that can take a rowtype from any table and create XML. Once I get the oracle.sql.ARRAY into my code, I am okay. I just can't seem to pass it in. I have pasted my code below:
    Java:
    import oracle.sql.*;
    public class test {
    public static String sayHello() {
    return("Hello, World!");
    public static void genXML(oracle.sql.ARRAY a, oracle.sql.CLOB c) throws Exce
    ption {
    c.putString(1,"<test>This is a test!</test>");
    PL/SQL:
    create or replace package mike is
    type dummy_record is varray (1) of dummy%rowtype;
    PROCEDURE GENERATE_XML(i dummy_record, c CLOB);
    FUNCTION SAYHELLO RETURN varchar2;
    end mike;
    show errors
    create or replace package body mike is
    PROCEDURE GENERATE_XML(i dummy_record,c CLOB)
    AS LANGUAGE JAVA
    NAME 'test.genXML(oracle.sql.ARRAY,oracle.sql.CLOB)';
    FUNCTION SAYHELLO RETURN varchar2
    AS LANGUAGE JAVA
    NAME 'test.sayHello() return java.lang.String';
    end mike;
    show errors
    DDL:
    SQL> describe dummy
    Name Null? Type
    USERNAME VARCHAR2(20)
    ID NUMBER
    Test Script:
    declare
    m Mike.dummy_record := Mike.DUMMY_RECORD();
    c CLOB;
    begin
    m.extend;
    select xml into c from t_clob;
    for rec in (select * from dummy)
    LOOP
    m(1) :=rec;
    mike.generate_xml(m,c);
    end loop;
    end;
    And finally, the output:
    declare
    ERROR at line 1:
    ORA-21700: object does not exist or is marked for delete
    ORA-06512: at "MMANGINO.MIKE", line 0
    ORA-06512: at line 10
    Sorry this post is so long, but I wanted it to be complete!
    Mike

    The first solution is to not do that in java in the first place.
    DDL should be in script files which are applied to oracle outside of java.
    Other than I believe there are some existing stored procedures in Oracle that take DDL strings and process them. Your user has to have permission of course. You can track them down via the documentation.

Maybe you are looking for