Stop native call from java

I know there are topics related to timeout, stop or kill native call but it seems there is no good answer for me.
I have a java class as the caller to call a native C function with double arrays as input. The C function perform some kind of computation using 3rd party FORTRAN functions. If we terminate the java, how to terminate/stop/or exit the C function?
Here is the partial of java class
public class PolyFit {
    public native double[] polyFit(int[]iParams, double[] dParams,
                                    double[] xx, double[] yy, int col);
    static {
        try {
            System.loadLibrary("polylib");
        } catch (UnsatisfiedLinkError e) {
            System.out.println ("Failed to load polylib");
            e.printStackTrace();
    public PolyFit() {
}The parent java class is a sub class of Thread that calls the PolyFit when running as a thread:
    int col2 = 2;
    for() { //more than 1000 pairs of inputX and inputY
        //iParams, dParams, inputX, inputY are assigned before
         PolyFit polyFit = new PolyFit();
        double[]output = polyFit .polyFit(iParams, dParams, inputX, inputY, col2);
    }Here is native C function (partial)
#include "PolyFit.h"
JNIEXPORT jdoubleArray JNICALL Java_org_ciit_stat_PolyFit_polyFit
            (JNIEnv *env, jobject obj, jintArray ja, jdoubleArray jda,
            jdoubleArray jdinX, jdoubleArray jdinY, jint col) {
    jdouble *output;   
    jdoubleArray dbArray = (*env)->NewDoubleArray(env, MAX);
    (*env)->SetDoubleArrayRegion(env, dbArray, MIN, MAX, output);
   free(output);
    return dbArray;
}Every call of polyFit .polyFit() may take less than 1 millisecond to several second. In case the time exceeds a threadhold, i.e. 10 second, we want to stop the thread. However, I can't find the way to stop or exit the C function.
Any ideas are highly appreciated.

This is C code, and since there is no portable way to interrupt C code, there's nothing that can be done. In Unix a SIGINT can do the trick, but only by killing the whole address space. There are some thread APIs that attempt to do this, but they are either very unsafe or require cooperation from the code which is being interrupted.
Your best bet is to code your CPU-intensive code to check a global (or thread-specific) flag for a requested interrupt, and cleanly exit back to the JNI wrapper, returning a flag value to acknowledge the interruption. A wrapper routine around the native method can then throw a Java exception, or block and retry, or whatever you want it to do.
Note that Thread.stop is deprecated. There is no earthly way to cleanly interrupt either Java or C code, unless it cooperates with the interrupter.

Similar Messages

  • Dll call from java using Jbuilder?

    Please?
    Does anyone know how I do dll calls from java (jubuilder).
    I have tried but did not manage to get it wright???
    / thanks carlos

    Research JNI (java native interface)

  • Duration of an Abap Function call from Java using Jco3

    Hi guys!
    I would like to use this discussion to get some refernces of the duration Timespan of an RFC call from Java to SAP. At the moment, i need at last about 200ms to call the Abap function. I'm just using one simple import and export parameter (so no deep structures). I think that the reason for my poor performance is, that the Java Tool and the SAP instance are not in the same network. So, i hope some of you have some data, how fast an RFC call from Java using Jco can be executed.
    greetings, Hannes

    Hi Hannes,
    I think you have already got the answer to your question - the network set-up you have is probably the bottleneck.  Whenever I've worked with Java <-> ABAP and they are in the same network, I've had no performance problems at all.
    Does your RFC contain any complex logic or business processes?  Are you able to try and call something that does nothing, say it just accepts an input string and returns it straight away as an export.  Do you have any scope for testing with your Java tool on the same network as the SAP system?
    Cheers,
    G.

  • I teach Spinning- is it possible to stop incoming calls from interrupting the music?

    I teach Spinning- is it possible to stop incoming calls from interrupting the music? I have the newest iphone.

    Turn on airplane mode.
    That turns off the cellphone network so no-one can call you.
    Don't worry they will get diverted to the answerphone.

  • How can i measure BAPI runtime which has called from JAVA

    Hi abapers
    how can i get run time for BAPI called from JAVA through JCO.
    i know that i can use SE30 from ABAP by executing from SAP.
    may be ST05 useful for me i did it but when display trace
    i am getting big list by seeing this list i am not able to find the runtime for that BAPI.
    please any one can explain
    reagdrs
    ramesh

    Hi Ramesh,
       Irrespective of whether the call is from an external system or within sap, the bapi will be executed in R/3 only.
    So, you can safely measure the runtime using se30 only.
    If it is taking more time when called from JCo , then you can be sure that the problem is not with SAP and is actually due to the JCo connectivity with R/3.
    Regards,
    Ravi

  • Calling a native library from Java

    Hello,
    I'm trying to call a native method (windows dll) from a web service implemented in Java. I've confirmed that the class I've created to call the native method works when used outside of my web service (ie. in a standard Java application). However, when I try to use the class in the web service, an exception is thrown when
    System.loadLibrary("MyLibrary");
    is executed. The exception thrown is:
    InvocationTargetException
    JAXRPCSERVLET28: Missing port information
    Does any one have any suggestions as to what might be causing this error?
    Thanks

    There are basically 3 steps to calling a native method from your Java code.
    1. Create a C/C++ stub function that will translate between your Java call and the native C method.
    2. Create the dll that exports the stub function.
    3. Invoke the System.loadLibrary("myDllName") method.
    Here's what I did to learn how to use the JNI.
    I first created the class that would be calling the dll:
    public class CallDll
    /** Creates a new instance of CallDll */
    public CallDll()
    static
    //LVtoJava is my dll name.
    System.loadLibrary("LVtoJava");
    //AddDll is the name of the function I'm exporting from my Dll
    //It does not have to be static
    public native static double AddDll(int func, double x, double y);
    I then used the javah utility in the jdk/bin directory to create the C stub header file. Once you have the generated stub header file, you can create an implementation file, and compile it into a dll.
    //My C++ stub, generated by javah utility
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class LabViewDll_CallDll */
    #ifndef IncludedLabViewDll_CallDll
    #define IncludedLabViewDll_CallDll
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: LabViewDll_CallDll
    * Method: AddDll
    * Signature: (IDD)D
    JNIEXPORT jdouble JNICALL Java_LabViewDll_CallDll_AddDll
    (JNIEnv *, jclass, jint, jdouble, jdouble);
    #ifdef __cplusplus
    #endif
    #endif
    You may want to note the stub function's signature and how it decorates the function name that you created from your Java class. Do not modify it, as the format is required by the JNI. The javah utility appends the fully qualified package name and the word Java, separated by underscores, to your original function name. You do not need to change the name in your Java class.
    All the other special key words in the function's signature are defined in the jni.h or the jni_md.h (if your using windows).
    You may want to refer to the JNI documention on Sun's website. The book I learned out of is the Core Java Volume 2, published by Sun Microsystems Press. It goes through the details of invoking your first native function and I've found it to be a good reference.
    Hope this helps,
    PS. I seemed to have found the issue with calling my dll from a web service. My dll is actually calling another dll and that seems to be the source of my problems. When I removed the call to the 2nd dll, everything worked fine. So now I need to figure out why the 2nd dll call is an issue.
    Any suggestions?

  • Calling native functions from java w/out DLL

    If I invoke a JVM inside my c++ app and try to start up a class that calls a native function, do I still need a DLL for that? Or will it look to my header file and then look to my implementation somewhere in a c++ class?
    For example:
    WinMain() - Invokes JVM and loads "HelloWorld" java class, then calls its 'main' method.
    HelloWorld.java - 'main' method calls "displayHello();" a native function.
    HelloWorld.h - defines displayHello native interface
    So it looks simply to the cpp implementation of the interface...I tried executing this but it isnt working...is it even possible?

    OK, I attempted what you posted by writing the following code... please look at because I get a 'main' not found error. I am trying to execute this from a win32 app...
    Callbacks.java:
    class Callbacks {
      private native void nativeMethod(int depth);
      private void callback(int depth) {
        if (depth < 5) {
          System.out.println("In Java, depth = " + depth + ", about to enter C");
          nativeMethod(depth + 1);
          System.out.println("In Java, depth = " + depth + ", back from C");
        } else
          System.out.println("In Java, depth = " + depth + ", limit exceeded");
      public static void main(String args[]) {
        Callbacks c = new Callbacks();
        c.nativeMethod(0);
    }InvokeJVM.cpp:
    #include "InvokeJVM.h"
    //Log any windows errors
    void InvokeJVM::LogWin32Error(const char * pTitle){
         PCHAR pBuffer;   
         LONG  lError = GetLastError ( );
         FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
              NULL,                   
              lError,                   
              MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),                   
              (char *)&pBuffer,                   
              0,                   
              NULL );
         //LogError ("Win32 error: %s %s\n",pBuffer,pTitle);
         LocalFree ( pBuffer );
    //Get a string returned from the windows registry
    bool InvokeJVM::GetStringFromRegistry(HKEY key, const char *name, unsigned char *buf, int bufsize){
         DWORD type, size;
         if (RegQueryValueEx(key, name, 0, &type, 0, &size) == 0 && type == REG_SZ && (size < (unsigned int)bufsize)){
              if (RegQueryValueEx(key, name, 0, 0, buf, &size) == 0){
                   return true;
         return false;
    //Get the path to the runtime environment
    bool InvokeJVM::GetPublicJREHome(char *buf, int bufsize){
         HKEY key, subkey;   
         char version[MAX_PATH];  
         /* Find the current version of the JRE */
         if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, JRE_KEY,0,KEY_READ,&key)!=0){
              //LogError("Error opening registry key '" JRE_KEY "'\n");          
              return false;   
         if(!GetStringFromRegistry(key,"CurrentVersion",(unsigned char *)version, sizeof(version))){
              //LogError("Failed reading value of registry key:\n\t"JRE_KEY "\\CurrentVersion\n");          
              RegCloseKey(key);          
              return false;   
         if(strcmp(version, DOTRELEASE)!= 0){
              //LogError("Registry key '" JRE_KEY "\\CurrentVersion'\nhas value '%s', but '" DOTRELEASE "' is required.\n", version);
              RegCloseKey(key);          
              return false;   
         /* Find directory where the current version is installed. */   
         if(RegOpenKeyEx(key,version,0,KEY_READ, &subkey)!= 0){
              //LogError("Error opening registry key '"JRE_KEY "\\%s'\n", version);          
              RegCloseKey(key);          
              return false;   
         if(!GetStringFromRegistry(subkey, "JavaHome", (unsigned char *)buf, bufsize)){
              //LogError("Failed reading value of registry key:\n\t"JRE_KEY "\\%s\\JavaHome\n", version);          
              RegCloseKey(key);          
              RegCloseKey(subkey);          
              return false;   
         RegCloseKey(key);   
         RegCloseKey(subkey);   
         return true;
    //Native interface call to printf
    jint JNICALL _vfprintf_(FILE *fp, const char *format, va_list args){
         //LogError(format,args);     
         return 0;
    //Native interface call if the VM exited
    void JNICALL _exit_(jint code){     
         //LogError("VM exited");     
         exit(code);
    //Native interface call if the VM aborted
    void JNICALL _abort_(void){
         //LogError("VM aborted");     
         abort();
    //Load the Java Virtual Machine
    void InvokeJVM::LoadJVM(char* dir){
         HINSTANCE handle;     
         JavaVMOption options[5];     
         char JREHome[MAX_PATH];     
         char JVMPath[MAX_PATH];                                             
         char classpathOption[MAX_PATH];     
         char librarypathOption[MAX_PATH];
         if(!GetPublicJREHome(JREHome, MAX_PATH)){          
              //LogError("Could not locate JRE");          
              abort();     
         strcpy(JVMPath,JREHome);     
         strcat(JVMPath,"\\jre\\bin\\client\\jvm.dll");
         if ((handle=LoadLibrary(JVMPath))==0) {          
              //LogError("Error loading: %s", JVMPath);          
              abort();   
         CreateJavaVM_t pfnCreateJavaVM=(CreateJavaVM_t)GetProcAddress(handle,"JNI_CreateJavaVM");
         if (pfnCreateJavaVM==0){          
              //LogError("Error: can't find JNI interfaces in: %s",JVMPath);          
              abort();     
         strcpy(classpathOption,"-Djava.class.path=");
         strcat(classpathOption,dir);     
         strcat(classpathOption,";");     
         strcat(classpathOption,JREHome);     
         strcat(classpathOption,"\\lib");     
         strcat(classpathOption,";");
         strcat(classpathOption,JREHome);     
         strcat(classpathOption,"\\lib\\comm.jar");     
         strcpy(librarypathOption,"-Djava.library.path=");     
         strcat(librarypathOption,JREHome);     
         strcat(librarypathOption,"\\lib");
         OutputDebugString("classpath option=");     
         OutputDebugString(classpathOption);     
         OutputDebugString("\n");     
         OutputDebugString("librarypath option=");     
         OutputDebugString(librarypathOption);     
         OutputDebugString("\n");
         options[0].optionString=classpathOption;
         options[1].optionString=librarypathOption;          
         options[2].optionString="vfprintf";     
         options[2].extraInfo=_vfprintf_;     
         options[3].optionString="exit";     
         options[3].extraInfo=_exit_;     
         options[4].optionString="abort";     
         options[4].extraInfo=_abort_;
         vmArgs.version = JNI_VERSION_1_2;
         vmArgs.nOptions = 5;   
         vmArgs.options  = options;  
         vmArgs.ignoreUnrecognized = false;
         if(pfnCreateJavaVM(&jvm,(void**)&env, &vmArgs) != 0){
              //LogError("Could not create VM");
              abort();     
    }Winmain.cpp:
    #define WIN32_MEAN_AND_LEAN
    #define WIN32_EXTRA_LEAN
    #include <windows.h>
    #include "oglwindow.h"          // the OpenGL window class
    #include "vector.h"
    #include "engine.h"               // the engine's main class
    #include "BrimstoneEngine.h"
    #include "InvokeJVM.h"
    JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *, jobject){
        MessageBox(NULL, "Hello From Java!", "Error", MB_OK);
        return;
    JNIEXPORT void JNICALL Java_Callbacks_nativeMethod(JNIEnv *env, jobject obj, jint depth){
      jclass cls = env->GetObjectClass(obj);
      jmethodID mid = env->GetMethodID(cls, "callback", "(I)V");
      if (mid == 0) {
        return;
      printf("In C, depth = %d, about to enter Java\n", depth);
      env->CallVoidMethod(obj, mid, depth);
      printf("In C, depth = %d, back from Java\n", depth);
    JNINativeMethod methods[] = {"nativeMethod","()V", Java_Callbacks_nativeMethod};
    WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int nCmdShow){
         InvokeJVM javaVirtualMachine;
         int loopRet;
         javaVirtualMachine.running = false;
         CoInitialize(NULL);
         if (!COGLWindow::RegisterWindow(hInst)){
              MessageBox(NULL, "Failed to register window class", "Error", MB_OK);
              return -1;
         BrimstoneEngine *engine = NULL;
         try{
              char path[MAX_PATH];  
              char drive[MAX_PATH];   
              char file[MAX_PATH];   
              char dir[MAX_PATH];   
              char ext[MAX_PATH];
              jclass  cls, cls1;     
              jmethodID mid;     
              jobjectArray args;
              jint err;
              _splitpath(path,drive,dir,file,ext);          
              javaVirtualMachine.LoadJVM(dir);     
              if(javaVirtualMachine.env == NULL){               
                   MessageBox(NULL, "Could not load VM", "Error", MB_OK);
                   abort();          
              if(GetModuleFileName(NULL, path, MAX_PATH) == 0){               
                   javaVirtualMachine.LogWin32Error("Getting module filename");          
                   abort();          
              cls = javaVirtualMachine.env->FindClass("Callbacks");
              if(cls == NULL){               
                   MessageBox(NULL, "Could not find class %s (or its superclass)", "Error", MB_OK);
                   exit(-1);          
              err = javaVirtualMachine.env->RegisterNatives(cls, methods, 1 );
              mid = javaVirtualMachine.env->GetMethodID(cls, "main", "([Ljava/lang/String;)V");
              if(mid == NULL){
                   MessageBox(NULL, "Could not find method 'main'", "Error", MB_OK);
                   exit(-1);          
              args = javaVirtualMachine.env->NewObjectArray(2-2, javaVirtualMachine.env->FindClass("java/lang/String"), NULL);          
              if(args==NULL){               
                   MessageBox(NULL, "Could not create args array", "Error", MB_OK);
              for(int arg=0; arg < 2;arg++)     {               
                   javaVirtualMachine.env->SetObjectArrayElement(args, arg, javaVirtualMachine.env->NewStringUTF(argv[arg+2]));      
              javaVirtualMachine.env->CallStaticVoidMethod(cls,mid,args);     
              javaVirtualMachine.jvm->DestroyJavaVM();
              engine = new BrimstoneEngine("OpenGL Game", FALSE, 800, 600, 16);
              loopRet = engine->EnterMessageLoop();
              delete engine;
              return loopRet;
         catch(char *sz)
              MessageBox(NULL, sz, 0, 0);
              delete engine;
         CoUninitialize();
         return -1;
    }any help is always appreciated

  • Web Service call from java UDF in message mapping

    Hi,
           Is it possible to call a web service from inside a java UDF in message mapping? The webservice can be any standard one. If this is possible please let me know how this can be done.
    Regards,
    Shiladitya

    Hi Shila,
                 Hope u remember me
    Here is the standard code used to call webservice from Java UDF
    public String setSoapAction(String SOAPAction,Container container){
    try{
    DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey soapurl = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/SOAP" , "THeaderSOAPACTION");
    conf.put(soapurl, SOAPAction);
    return "";
    }catch(Exception e){
    e.getMessage();
    return "";
    Regards,
    Arijit

  • RFC call from java webdynpro

    Hi,
    I'm creating a Java Webdynpro where I call RFC's from SAP.
    For the images in the webdynpro, I call the standard SAP function 'CVAPI_DOC_VIEW'
    When I execute the function in SAP, I get the url to the contentserver with the correct image.
    After calling the same function in my Java Webdynpro, the url is empty.
    I've checked the importing parameters after calling from webdynpro and SAP and they are the same.
    After debugging, I saw that the function 'CVAPI_DOC_VIEW' is the problem. He's exporting an empty url after calling from the webdynpro.
    Does anybody knows the possible fault and solution for my problem?

    I'm not an ABAPer but the last time I've dealt with DMS from Web Dynpro an ABAPer wrote a custom function that gets the file content (XSTRING) by sending DMS parameters (documenttype, documentnumber, documentversion, documentpart).
    After getting the XSTRING from my Web Dynpro Java, I convert it to byte[] and created URL by using WDResourceFactory.
    Hope it helps...
    Omri

  • How stored procedure get executed when called from java

    When we create a stored procedure or function in oracle, it is compiled and stored there. From java when we call them no compilation is performed its a simple call. When a function or stored procedure is invoked from multiple instance of java objects(for a single session), does the stored procedure clone it self so that it can be called by different java objects which I think not possible at all. In such cases when one java object is interacting with the stored procedure, does other java objects go on a wait state. What happens if sessions are different.
    Please help.

    >
    does oracle creates multiple instance of a particular stored procedure for different sessions or connections. if not then there might be some kind of waiting principle followed.. what happens exactly
    >
    What happens exactly is detailed in Chap. 14 Memory Architecture ni the Database concepts doc
    http://docs.oracle.com/cd/E14072_01/server.112/e10713/memory.htm#i21266
    The code is shared but the data isn't (see the lone exception to this below).
    See the section on the Library Cache
    >
    Program Units and the Library Cache
    The library cache holds executable forms of PL/SQL programs and Java classes. These items are collectively referred to as program units.
    The database processes program units similarly to SQL statements. For example, the database allocates a shared area to hold the parsed, compiled form of a PL/SQL program. The database allocates a private area to hold values specific to the session that runs the program, including local, global, and package variables, and buffers for executing SQL. If multiple users run the same program, then each user maintains a separate copy of his or her private SQL area, which holds session-specific values, and accesses a single shared SQL area.
    >
    The exception is when code uses the SERIALLY_REUSABLE pragma. In that case the memory for package state is in the SGA and users do not have their own copy in their UGA.
    See the SERIALLY_REUSABLE pragma in the PL/SQL Language doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/seriallyreusable_pragma.htm
    >
    The global memory for serially reusable packages is pooled in the System Global Area (SGA), not allocated to individual users in the User Global Area (UGA). That way, the package work area can be reused. When the call to the server ends, the memory is returned to the pool. Each time the package is reused, its public variables are initialized to their default values or to NULL.
    Serially reusable packages cannot be accessed from database triggers or other PL/SQL subprograms that are called from SQL statements. If you try, the database generates an error.

  • Passing UDT TABLE of VARCHAR as an Input parameter in Stored procedure call from java

    I have following Type defined at the schema: ident_arr IS TABLE OF VARCHAR2(100) which is type of one of the input parameters. I am able to create oracle.sql.ARRAY object to map it with this UDT before calling my stored procedure from java. When I execute my stored procedure, I get the following error:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'P_PV_WCC_INSERT'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    I have already checked all other parameter types.

    Hello,
    Thank you, guys, for advice. I should have explained calling context before, but what I basically need to do is to see if procedure(arg1, list(record(arg2, arg3))) returns true.
    I see array binding wouldn't fit there nicely. Internal procedure calls would be proc(next(arg1), next(arg2), next(arg3)) - if all these return true, external call should also return true. I would need to make a list of repeating values of arg1 and separate list(record(arg2, arg3)) into separate lists. I would also need to record whether the internal call returns true to deduce whether external call returns true.
    As I see no better way yet, I'll make Oracle procedure proc(arg1, arg2, arg3) and implement a loop in .NET side. If I optimize for performance, I'll probably pack the array of records into string and pass it for Oracle side to parse.
    Regards,
    Aurimas Pranskevicius

  • JavaFX hangs when called from Java

    Hello
    I am developing a java application with a JavaFX gui, the communication from Java works with an java interface. The communication works,but after a few updates the javaFX code hangs and subsequently the Java code also hangs.
    Is this a common problem, and so is there a common solution for this.

    JavaFX UI calls need to be done on the Event Thread. So if your Java Application has multiple threads or runs on a different Thread to need to wrap all callbacks to JavaFX in a deferAction like this:
    class YourFXClass extends YourJavaInterface {
       override public function someMethod(someArgument) {
            FX.deferAction(function() : Void {
                  // doSomething with someArgument
        }

  • ESB Webservice call from Java client

    Hi,
    i need to call webservice from Java client which inturn will call ESB
    I tried creating proxy from the WSDL in jDeveloper and tried setting the following end points
    My concrete WSDL path :http://10.237.25.63:8889/esb/wsil/SubroCaseESBSystem/InputRouter?wsdl
    My EM -path:"http://10.237.25.63:8889/event/subrotest/SubroInputrouter"
    When i call the concreteWSDL im getting
    "HTTP transport error: javax.xml.soap.SOAPException: java.security.PrivilegedActionException: javax.xml.soap.SOAPException: Bad response: 405 Method Not Allowed"
    If i call the EM pathim getting
    "javax.xml.rpc.soap.SOAPFaultException"
    Any guess as how i need to call my ESB from client.

    Hello Venkat,
    - I have created Java Proxy using Jdeveloper for ESB webservice and I usually use http://host:port/event/...?wsdl, and it creates stub which works without any modification. Let me know, may be I can try sending sample project
    - I would like to verify if you are having issue with Java client or ESB itself, are you able to execute that ESB process/service from EM test page or from any other BPEL process?
    Regards,
    Chintan

  • Call from Java Plsql Procedure with VArray as Out Parameter

    Hi,
    I have a Java web application(Tomcat server) that call a plsql procedure with Varray as OUT parameter.
    The Plsql code is perfectly compiled.
    When i run the application, I get the following error msg in my Tomcat window:
    java.sql.SQLException: ORA-06530: Reference to uninitialized composite
    ORA-06512: at "SEMS1.PACK_SEMSADMIN_OFFEREDJOBS", line 102
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:109
    3)
    at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStat
    {color:#0000ff}
    Doubt: Do I need to declare ArrayDescriptors to retrieve the VArray from the Plsql procedure.
    I think the below statement is enough; we need ArrayDescriptors only when we we wish to send a Plsql Object or Varray from Java code to the procedure. Plz correct me if not so.
    dbCallableStatement.execute();
    ARRAY SimpleOUTArray = (ARRAY) ((OracleCallableStatement) dbCallableStatement).
    getObject(Integer.parseInt(arlParameterOutIndex.get(i).toString()));{color}
    I am unable to realize where the mistake is?
    {color:#800000}
    {color}{color:#800000}
    VARRAY AND PROC DETAILS:
    TYPE STRUCT_JOB_DETAILS AS OBJECT
    APPL_NO NUMBER (10),
    S_FNAME VARCHAR2 (32 Byte),
    S_MI VARCHAR2 (32 Byte),
    S_LNAME VARCHAR2 (32 Byte),
    APPL_DATE DATE,
    DESCRIPTION VARCHAR2 (100 Byte),
    S_UCID VARCHAR2 (8 Byte)
    TYPE VARRAY_JOB_DETAILS IS VARRAY(100) OF STRUCT_JOB_DETAILS;{color}
    {color:#800000}PROCEDURE:{color}
    {color:#800000}CREATE OR REPLACE PACKAGE PACK_SEMSADMIN_OFFEREDJOBS
    AS
    TYPE Generic_Cursor_Type IS REF CURSOR;
    --TYPE varray_job_detail is VARRAY(100) OF STRUCT_JOB_DETAILS;
    --va_varray_job_detail varray_job_detail := varray_job_detail();
    va_varray_job_detail VARRAY_JOB_DETAILS := VARRAY_JOB_DETAILS();
    PROCEDURE Admin_Jobs_Offered_Rtr
    ic_status IN VARCHAR2,
    or_offered_jobs OUT Generic_Cursor_Type,
    va_varray_job_detail OUT VARRAY_JOB_DETAILS
    CREATE OR REPLACE PACKAGE BODY PACK_SEMSADMIN_OFFEREDJOBS
    AS
    PROCEDURE Admin_Jobs_Offered_Rtr
    ic_status IN VARCHAR2,
    or_offered_jobs OUT Generic_Cursor_Type,
    va_varray_job_detail OUT VARRAY_JOB_DETAILS
    AS
    vc_query VARCHAR2(15000) := '';
    vc_query_1 VARCHAR2(15000) := '';
    counter NUMBER := 1;
    vc_no NUMBER := 0;
    or_applicants_list Generic_Cursor_Type;
    TYPE type_appln_list IS RECORD
    job_no NUMBER(10),
    job_title VARCHAR2(50 BYTE),
    account_no VARCHAR2(10 BYTE),
    head_fname VARCHAR2(32 BYTE),
    head_minitial VARCHAR2(10 BYTE),
    head_lname VARCHAR2(32 BYTE),
    num NUMBER
    vn_appln_list type_appln_list;
    TYPE type_job_offered IS RECORD
    APPL_NO NUMBER (10),
    S_FNAME VARCHAR2 (32),
    S_MI VARCHAR2 (32),
    S_LNAME VARCHAR2 (32),
    APPL_DATE DATE,
    DESCRIPTION VARCHAR2 (100),
    S_UCID VARCHAR2 (8)
    vn_job_offered type_job_offered;
    BEGIN
    vc_query := vc_query || ' SELECT jobs.job_no,job_title, account_no, head_fname, head_minitial, head_lname, num';
    vc_query := vc_query || ' FROM jobs, ( ' ;
    vc_query := vc_query || ' SELECT jobs.job_no,count(*) as num' ;
    vc_query := vc_query || ' FROM student_apps ,jobs ' ;
    vc_query := vc_query || ' WHERE jobs.job_no = student_apps.job_no' ;
    vc_query := vc_query || ' AND (student_apps.status in (''o'',''t'')) '; --|| ic_status || ')' ;
    vc_query := vc_query || ' AND jobs.status not in (''z'', ''Z'')' ;
    vc_query := vc_query || ' GROUP BY jobs.job_no' ;
    vc_query := vc_query || ' ) no_apps_off' ;
    vc_query := vc_query || ' WHERE jobs.job_no = no_apps_off.job_no' ;
    dbms_output.put_line('Executed Query_1');
    va_varray_job_detail := VARRAY_JOB_DETAILS();
    va_varray_job_detail.extend(100);
    OPEN or_offered_jobs FOR vc_query;
    LOOP
    FETCH or_offered_jobs INTO vn_appln_list;
    EXIT WHEN or_offered_jobs%NOTFOUND;
    vc_query_1 := '';
    vc_query_1 := vc_query_1 || ' SELECT stud_apps.appl_no APPL_NO, stud_apps.s_fname S_FNAME, ';
    vc_query_1 := vc_query_1 || ' stud_apps.s_mi S_MI, stud_apps.s_lname S_LNAME, ';
    vc_query_1 := vc_query_1 || ' stud_apps.appl_date APPL_DATE, look_up.description DESCRIPTION, ' ;
    vc_query_1 := vc_query_1 || ' stud_apps.s_ucid S_UCID ' ;
    vc_query_1 := vc_query_1 || ' FROM student_apps stud_apps,jobs jbs,lookup look_up' ;
    vc_query_1 := vc_query_1 || ' WHERE stud_apps.status in (''o'',''t'') '; --(' || ic_status || ') ' ;
    vc_query_1 := vc_query_1 || ' AND jbs.job_no = stud_apps.job_no' ;
    vc_query_1 := vc_query_1 || ' AND jbs.status not in (''z '', ''Z'')' ;
    vc_query_1 := vc_query_1 || ' AND stud_apps.status = look_up.code ' ;
    vc_query_1 := vc_query_1 || ' AND look_up.type = ''st''' ;
    vc_query_1 := vc_query_1 || ' AND stud_apps.job_no = ''' || vn_appln_list.job_no || ''' ' ;
    vc_query_1 := vc_query_1 || ' ORDER BY appl_date' ;
    dbms_output.put_line('Executed Query_2');
    OPEN or_applicants_list FOR vc_query_1;
    LOOP
    FETCH or_applicants_list INTO vn_job_offered;
    EXIT WHEN or_applicants_list%NOTFOUND;
    va_varray_job_detail(counter).APPL_NO := vn_job_offered.APPL_NO;
    va_varray_job_detail(counter).S_FNAME := vn_job_offered.S_FNAME;
    va_varray_job_detail(counter).S_MI := vn_job_offered.S_MI;
    va_varray_job_detail(counter).S_LNAME := vn_job_offered.S_LNAME;
    va_varray_job_detail(counter).APPL_DATE := vn_job_offered.APPL_DATE;
    va_varray_job_detail(counter).DESCRIPTION := vn_job_offered.DESCRIPTION;
    va_varray_job_detail(counter).S_UCID := vn_job_offered.S_UCID;
    counter := counter + 1;
    END LOOP; --end of FOR
    CLOSE or_applicants_list;
    END LOOP; -- end of FETCH
    END Admin_Jobs_Offered_Rtr;
    END PACK_SEMSADMIN_OFFEREDJOBS;
    /{color}
    Reqire help plzzzz !!!
    Thanks.

    Originally posted by JDBC Development Team:
    It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
    cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
    cstmt.execute ();
    ARRAY array = (ARRAY) cstmt.getObject (idx);
    Thanks for your reply.
    I have to use:-
    OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
    ( "{call proj_array(?)}" ) ;
    for retrieving a collection as an OUT parameter.
    This gives me the errors:-
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    How do I get rid of these errors?
    null

  • Create Opportunity Header api calling from java

    Hi,
    I need to call the Create Opportunity Header api from java but from looking at the spec this is going to be impossible without wrapping the API in some more PLSQL so that it is exposed using SQL types rather than PLSQL types which are not supported in JDBC.
    Is this correct? Are there other approaches which you can suggest.
    Peter.

    See this
    http://forum.java.sun.com/thread.jsp?forum=52&thread=94146

Maybe you are looking for

  • How do I unregister someone's MacBook?

    I recently bought a MacBook Air from a seller off of rakuten, but when I go to register it under my Apple ID, it says "According to our records, this serial number is registered to another Apple ID. If you have more than one Apple ID, log in to My Su

  • Adding authorization object for "Function Group"s ?

    Is it possible to add any authorization object for any function group ? We have an issue i.e. whenever user "XYZ" is getting some Windows Excel related error whenever trying call an excel report from BW server. System log related to "XYZ" user shows

  • Domain Group Policy changes causes clients to be unable to connect to WSUS for Windows Updates

    Domain Controller is Windows Server 2008 R2 64-bit, Group Policy Management version 6.0.0.1. WSUS server is Windows Server 2008 Enterprise 32-bit, Update Services version 3.2.7600.226. Client machines are Windows 7, some are 64-bit and some are 32-bi

  • How to join PLSQL nested table with normal tables ?

    my requirement is to delete the rows in a normal oracle table in one statement, based on the values collected in a PL/SQL nested table which is filled by another program. In the following example, i need to delete the rows in the table c_journals whe

  • Trying to add KPLU jazz radio station to itunes or desk top

    Hi good people: I have been trying to add the jazz radio station, KPLU, to my Library in iTunes and have got as far as listing it in the library but I can't onpen it up to play the music. I have imported plug ins and tried all most everything. Some t