Passing int arrays to strings

I'm having trouble passing an array of integers to a string and vice versa i.e. the array has
element[0] =1
element[1] =0
element[2] =0 but it can hold up to 16 elements
what I want is for this array which holds a binary number represented by ints to be represented as the string "001". Im passing the method an array then I want it to loop the length of the array and store each element as a part of the string. I then want to add the number to another number put it back in an array and return it. If anyone has any help I would appreciate it.
Thanks.

public class YourClass {
     public static String arrayToString(int[] theArray) {
          int lim = theArray.length;
          StringBuffer sb = new StringBuffer();
          for (int i = 0; i < lim; i++) {
               sb.append(String.valueOf(theArray));
          return sb.toString();
     public static int[] stringToArray(String theString) {
          int lim = theString.length();
          int[] theArray = new int[lim];
          for (int i = 0; i < lim; i++) {
               theArray[i] = Integer.parseInt(theString.substring(i, i+1));
          return theArray;
     public static void main(String[] args) {
          int[] theArray = {1,0,0,1,1};
          String theString = arrayToString(theArray);
          System.out.println(theString);
          int[] theArray2 = stringToArray(theString);
          System.out.println(arrayToString(theArray2));

Similar Messages

  • How to pass int array as an IN parameter to PLSQL Procedure

    Hi,
    How to pass int array in java to a stored procedure througn jdbc
    and what type of data type I should declare to this IN parameter
    in PLSQL Procedure.
    Thanks,
    Simi

    Hi,
    The best way to do what you want depends on what you want.  Start by describing what you need to do.  It's best to post some sample data (CREATE TABLE and INSERT statments) and what results you want from that sample data.  (See the forum FAQ: https://forums.oracle.com/message/9362002)
    If you have ideas about how to do the job (e.g., populating a temporary table) it can be helpful to include those, too, but distinguish clearly between WHAT you need to do and HOW you might do it.
    As Bencol suggested, a SYS_REFCURSOR might be the best way to pass back the results.
    Since you didn't post your table, or even describe what you wanted to do with it, I'll illustrate using scott.emp, which is probably on your system.
    Say you wanted a procedure that took a DATE as an argument, and returned a some designated columns (empno, ename and hiredate in the example below) for all employees hired on or after the given DATE.  You might write a procedure like this:
    CREATE OR REPLACE PROCEDURE  hired_since
    (   start_date  IN   DATE
    ,   out_data    OUT  SYS_REFCURSOR
    AS
    BEGIN
        OPEN out_data FOR
            SELECT  empno, ename, hiredate
            FROM    scott.emp
            WHERE   hiredate  >= start_date;
    END  hired_since;
    SHOW ERRORS
    You can test it in SQL*Plus like this:
    VARIABLE   c REFCURSOR
    EXEC  hired_since (DATE '1982-01-01', :c);
    PRINT :c
    The output I got from this test was:
         EMPNO ENAME      HIREDATE
          7788 SCOTT      19-APR-87
          7876 ADAMS      23-MAY-87
          7934 MILLER     23-JAN-82

  • Using JNI to pass an array of Strings to C and back from C

    I have some C code that I want to integrate with a new Java application and I need to be able to pass an array of strings to the C program and then the C program needs to be able to build an array of strings that is passed back to the Java program. I've got the first part working so that I can pass an array of strings to the C program and display them, but I can't figure out how to build the strings in C so that that when Java gets back control, it can display the strings tha were built in the C program.
    Has anyone done this? Do you have some sample code?

    I have a program which is written in C. I can give you the whole project as it is in a zip file. You'll need VC to work with it. By the way, I am using Windows for development. Should you need it, I'll mail you the same. Give me your mail address.

  • How do I pass an array of strings? (Help Me... Please!!! .Read Me....)

    Dear All.
    Help Me...
    English is not very good. Google translator is used.
     How do I pass an array of strings?
    Please refer to the VB program
     ===========================================
    Private Sub m_btn_Click()
        Dim nReturn As Long
        Dim sPpid As String
        Dim sMdln As String
        Dim sSoftRev As String
        Dim nCount As Long
        Dim saCCodes(2) As String
        Dim naPCount(2) As Long
        Dim saPNames(10) As String
        sPpid = "PPID001"
        sMdln = "Mdln"
        sSoftRev = "Rev001"
        nCount = 2
        saCCodes(0) = "1"
        naPCount(0) = 5
        saPNames(0) = "Param001"
        saPNames(1) = "Param002"
        saPNames(2) = "Param003"
        saPNames(3) = "Param004"
        saPNames(4) = "Param005"
        saCCodes(1) = "2"
        naPCount(1) = 5
        saPNames(5) = "Param006"
        saPNames(6) = "Param007"
        saPNames(7) = "Param008"
        saPNames(8) = "Param009"
        saPNames(9) = "Param010"
        nReturn = m_XGem.GEMReqSend(sPpid, sMdln, sSoftRev, nCount, saCCodes(0), naPCount(0), saPNames(0))
        If (nReturn = 0) Then
            Call Me.AddMessage("[EQ ==> XGEM] GEMReqSend successfully")
        Else
            Call Me.AddMessage("[EQ ==> XGEM] Fail to GEMReqSend (" & nReturn & ")")
        End If
    End Sub
    =================================================
    nCount, naPCount enough saCCodes, saPNames value must be sent.
    How to handle an array of strings in LabView is impatient.
    I want to VB program implemented in LabView.

    Have you actually tried to right click on the according node parameter and select Create->Constant or Create-Control??
    And I don't see any string array in the parameter list. That are all simple strings and the VB code in your first post clearly shows that the call to the function only indexes the first element of those arrays to be passed to the function, not the entire array.
    If the function really reads arrays despite being declared as only taking strings then it is using some weirdo VB trickery and there will be no way to replicate that in LabVIEW.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • JSP Tag- Passing an array of string as an Attribute

    Can I pass an array of String as an attribute to a JSP Tag? I read the specification but It does not say any thing about this.
    Thanks in Advance.

    I thought JSP tags had to deal strictly with string values?

  • How to convert an int array to string array?

    Hi,
    Can anyone please help me with this question?
    int number={4,6,45,3,2,77};
    I like to convert this into a list and sort
    List mylist = Arrays.asList(number);
    Collections.sort(mylist);
    But first I need to convert the int array to String array.
    Please advise. Thanks.

    If you want to convert your int array to a String array, you have no choice but doing a conversion element by element in a for loop.
    However, if the sort method doesn't behave as desired, you can use the one with 2 parameters, the second parameter being a comparator class.
    Check the javadoc for more information : http://java.sun.com/j2se/1.3/docs/api/java/util/Collections.html
    /Stephane

  • Array of strings in container won't pass to array of strings in LabVIEW cluster

    I'm new to TestStand but am a CLD.  I've taken a 3-day custom course that covered most of TestStand Core 1 and some of Core 2.  I'm using TestStand 2013 and LabVIEW 2013.
    I have a VI that needs an input of a cluster containing, in this order:
    1D array of strings named Column_Labels
    2D array of doubles named Results_Data
    1D array of paths named Graphics_File_Paths
    1D array of booleans named Pass_Fail
    In TestStand I created a custom data type called Maxim_Results from the VI module tab in the sequence.  When I reference a local (MINSYS_Reuslts) that is made from this Type I get the following error:
    No corresponding subproperty in argument 'Locals.MINSYS_Results' of type 'Maxim_Results' for cluster element 'Maxim_Results.Column_Labels'
    If, however, I reference each container element to each cluster element separatley there is no error:
    Can anyone help me understand why this is happening?
    Kelly Bersch
    Certified LabVIEW Developer
    Kudos are always welcome
    Solved!
    Go to Solution.

    Hey Kelly,
    I just set up the situation you described, and it worked properly for me. However, I did notice that in your example where you referenced each element individually, your Column_Labels element is actually called "Column_Lables". If this was also misspelled in the LabVIEW Cluster Passing setting for the custom type, it would cause the behavior you're seeing. Could this possibly be the case?
    Daniel E.
    TestStand Product Support Engineer
    National Instruments

  • How do you invoke a method with native int array argument?

    Hi,
    Will someone help me to show me a few codes samples on how to invoke a method which has only one argument, an int [] array.
    For exampe:
    public void Method1(int [] intArray) {...};
    Here is some simple code fragment I used:
    Class<?> aClass = Class.forName("Test2");
    Class[] argTypes = new Class[] {int[].class};
    Method method = aClass.getDeclaredMethod("Method_1", argTypes);
    int [] intArray = new int[] {111, 222, 333};
    Object [] args = new Object[1];
    args[0] = Array.newInstance(int.class, intArray);
    method.invoke(aClass, args);I can compile without any error, but when runs, it died in the "invoke" statement with:
    Exception in thread "main" java.lang.IllegalArgumentException: object is not an instance of declaring class
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at Test1.invoke_Method_1(Test1.java:262)
         at Test1.start(Test1.java:33)
         at Test1.main(Test1.java:12)
    Any help is greatly appreciated!
    Jeff

    Sorry, my bad. I was able to invoke static methods and instance methods with all data types except native int, short, double and float, not sure the proper ways to declare them.
    After many frustrating hours, I posted the message for help, but at that time, my mind was so numb that I created a faulted example because I cut and pasted the static method invocation example to test the instance method passing int array argument.
    As your post suggested, "args[0] = intArray;", that works. Thanks!
    You know, I did tried passing the argument like that first, but because I was not declaring the type properly, I ended up messing up the actual passing as well as the instantiation step.
    I will honestly slap my hand three times.
    jml

  • How can i cast array of string to int ?

                       while(st.hasMoreTokens()){
                                  test[count] = st.nextToken();
                                  count++;
                          }Since token deal with string, i have to pass them into String of array, but how can i convert all of them to int to perform arithmetic operation?

         public static void main (String[] args) throws IOException{
               DataInputStream dis = null;
                 String dbRecord = null;
                 int tokenCount = 0;
                 int numOfQuestion = 0;
                 int questionnAireNum = 0;
                 int postCode = 0;
                 int age = 0;
                 int gender = 0;
                 String [] response = new String[10];
                    File f = new File("polldata.txt");
                    FileInputStream fis = new FileInputStream(f); 
                    BufferedInputStream bis = new BufferedInputStream(fis); 
                    dis = new DataInputStream(bis);
                    // read the first record of the database
                    while ( (dbRecord = dis.readLine()) != null) {
                       StringTokenizer st = new StringTokenizer(dbRecord, ",");
                       tokenCount = st.countTokens();
                       numOfQuestion = tokenCount-4;
                       String rquestionNum = st.nextToken();
                       questionnAireNum = Integer.parseInt(rquestionNum);
                       String rpostCode = st.nextToken();
                       postCode = Integer.parseInt(rpostCode);
                       String rAge  = st.nextToken();
                       age = Integer.parseInt(rAge);
                       String rGender = st.nextToken();
                       gender = Integer.parseInt(rGender);
                       for(int i=0; i<numOfQuestion;i++){
                            response[i] = st.nextToken();
                       }hi how come when i cast the string as int it prompt me error as shown below ? I wonder what causes this because this is normally how i cast string to int, somehow it won work this way with token.
    Exception in thread "main" java.lang.NumberFormatException: For input string: " 3"
         at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
         at java.lang.Integer.parseInt(Integer.java:447)
         at java.lang.Integer.valueOf(Integer.java:553)
         at test.main(test.java:43)

  • Need help on passing an array to  java routine from PL/SQL

    I got a math routine in java and the idea is have an array of integer and the java routine does some computatoin and then pass the array back to pl/sql
    and I google the web most code is calling pl/sql from java but not the other way round. any help will be really appreciated.
    {code}
    package tst;
    import java.util.*;
    public class plsql3 {
            private final static int factor1 = 2;
            public static void getFib2(int[] in, int[] out, int k){
                            for (int i=0;i<=k-1;i++){
                    out[i]= in[i] * factor1;
      public static void main(String[] arg){
         int[] in2 = {1,2,3,4,5};
         int[] out2= {0,0,0,0,0};
         getFib2(in2,out2,2);
         for ( int j = 0 ; j <= out2.length-1;j++) {
                    System.out.println(out2[j]);
    {code}
    {code}
    CREATE or replace PROCEDURE getfib5 (x IN OUT numlist, y IN OUT numlist, k in number)
    AS LANGUAGE JAVA
    NAME 'tst.plsql3.getFib2(int[], int[],int)';
    set serveroutput on format wraped;
    declare
      in2 numlist := numlist(1,2,3,4,5,6);
      out2 numlist := numlist(0,0,0,0,0,0);
    begin
    --in2(0) := 1;
    --in2(1) := 2;
    --in2(2) := 3 ;
    for i in 1..in2.count
      loop
        dbms_output.put_line(in2(i));
      end loop;
       for i in 1..in2.count
      loop
        dbms_output.put_line(out2(i));
      end loop;
      getFib5(in2,out2,2);
      for i in 1..in2.count
      loop
        dbms_output.put_line(in2(i));
      end loop;
       for i in 1..in2.count
      loop
        dbms_output.put_line(out2(i));
      end loop;
    --dbms_output.put_line(in2.count);
    end;
    {code}
    {code}
    javac -source 1.5 -target 1.5 tst/plsql3.java
    {code}
    Error report:
    ORA-00932: inconsistent datatypes: expected a value at argument position 1 that is convertible to a Java int got an Oracle named TYPE (ADT, REF etc)
    ORA-06512: at "TK1.GETFIB5", line 1
    ORA-06512: at line 18
    00932. 00000 -  "inconsistent datatypes: expected %s got %s"
    *Cause:   
    *Action:

    http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:3696816290928

  • How do I pass an array of structs to a C function using the dll flexible prototype adapter?

    What I want to do is pass into a C dll function a variably sized Array of structs of type TPS_Data. My Code compiles but when I run it in TestStand, I get an error -17001; Program Error. "Cannot allocate 0 size buffer Error in parameter 2, 'OpenFrdData'."
    I've allocated the Array of structs, and all of the information is there before I call my function, so is it my prototype? Or am I asking too much of the DLL Flexible Prototype Adapter to pass an Array of Structs?
    I can pass in a single struct of type TPS_Data and that works, but not an array.
    Here's the relevent code:
    typedef struct TPS_DATA
    char Report_Number[256];
    char System_Name[256];
    char Open_Date[256];
    char UUT_Part_Number[256];
    char UUT_Serial_Number[256];
    char UUT_Name[256];
    char Open_Employee_Name[256];
    char Open_Employee_Number[256];
    char Close_Employee_Name[256];
    char Close_Employee_Number[256];
    char Close_Date[256];
    } TPS_Data;
    typedef struct TPS_DATA_ARRAY
    TPS_Data DataRecord;
    } TPS_DataArray;
    long __declspec(dllexport) __stdcall OpenDialog (CAObjHandle Context, TPS_DataArray *TpsData[], const char *psFaultStr, char *sComments, const int nCount);

    OK,
    I can pass the data to the DLL function, using the following types:
    typedef struct StringArrayType
    char string[10][256];
    } StringArray;
    typedef struct MultiStringArrayType
    StringArray Record[10];
    } MultiStringArray;
    void __declspec(dllexport) __stdcall ATP_TestStructPassing(StringArray Strings)
    return;
    void __declspec(dllexport) __stdcall ATP_TestMultiStructPassing(MultiStringArray *Strings)
    return;
    But when the MultiStruct function Exits, TestStand reports an Error:
    -17501 "Unexpected Operating System Error" Source: 'TSAPI'
    There doesn't seem to be a way around this, and once the error occurs, I have to force quit TestStand. I've included the sequence file, and the dll code can be compiled from the fun
    ctions shown above.
    Any thoughts on how to get around this error would be greatly appreciated.
    Attachments:
    StructArrayPassing.seq ‏16 KB

  • How to pass an array which in the jsp to a javascript file

    now i have 2 files: jsp and js(javascript)
    i want pass an array which in the jsp to another file--> js file
    how can i do it ???
    can u give me some related links or some source codes as the references???
    thx

    bcos ....my senior has resigned!!! so i take over his job !!!!!
    depend on the talent and the project ....only that way to implement to whole project !!!!
    but , i had settled it already ....
    it is very simple
    in the middle.jsp
    Collection result = menuManager.getUserRoleMenu(webSessionUser.getGnuserId());
    String menuname[]=new String[110];
    int menucounter=0;
    Iterator vi = result.iterator();
    while(vi.hasNext())
    HashMap hm=(HashMap)vi.next();
    menuname[menucounter]=hm.toString();
    menucounter++;
    int i;
    String tempstr="";
    for(i=0;i<menuname.length;i++)
    tempstr+=menuname[i]+",";
    session.setAttribute("menuname",tempstr);
    %>
    <script language="javascript">
    menu123("<%=tempstr %>");
    </script>
    in the body,js
    function menu123(string123)
    //doing
    so ....through the script --menu123
    i can get the string from jsp to the js!!!!!
    is it very simple, but it spends my 2 days!!!
    i just learn javascript ....about 1 month !!!

  • Passing an array of objects to a method.

    Hi I'm building a program to act as a CD Collection Database. An array of objects represents the entries: Artist, Album and NUmber of Tracks. What I want to do is in the Menu, user to choose wether he or she wants to Add new CD to collection, print or quit, if he/she does then I call a method addNewEntry, to which i pass the array of objects called array, and I want the user to enter the entries each in turn, after that i want the program to return to the method Menu and ask if he or she wants to quit, print or add new cd. The idea is that the details entered already would be contained in the array of objects [0], so the next set of details go to [1] and then to [2] and so on. I have build up the code at this stage but i get an error while copmiling and im totally stuck. Im a beginner in Java.
    Here is the code:
    //by Andrei Souchinski
    //Mini Project: CD Collection Database
    //Designed for a grade F
    //Defining new class of objects to represent CD database entries.
    //A database entry consists of the artist name, the album name and number of tracks.
    //A single entry can be entered by the user typing the details in and the entry can be printed out.
    import javax.swing.*;
    import java.util.*;
    public class MiniProject
         public static void main (String[] args)     
              System.out.println("\tCD Collection Database\n");
              System.out.println("1. Add new Compact Disk to the Database");
              System.out.println("2. Print out current database entries");
              System.out.println("3. Quit\n");          
              theMenu();
         public static void theMenu()
              CompactDisk [] array = new CompactDisk[20];
              String menu;
              menu = JOptionPane.showInputDialog("What would you like to do?");
              if (menu.equals ("3"))
                   JOptionPane.showMessageDialog(null, "Thank You For Using our Service! \nGoodbye!");
                   System.exit(0);     
              if (menu.equals ("2"))
              if (menu.equals ("1"))
              addNewEntry(array);
              else
                   JOptionPane.showMessageDialog(null, "Please select your choice form the menu");
                   theMenu();
         public int addNewEntry(int newcd[])
                   int i;          
                   newcd[i] = (JOptionPane.showInputDialog("Please enter the name of the Artist"));
                   newcd[i] = (JOptionPane.showInputDialog("Please enter the name of the Album"));
                   newcd[i] = (Integer.parseInt (JOptionPane.showInputDialog("Please enter the number of tracks on this album")));
    //A Compact Disk entry consists of three attributes: artist name, album and number of tracks
    class CompactDisk
         public String artistname; //Instance variables for artistname, albumname and numberoftracks.
         public String albumname;
         public int numberoftracks;
         public CompactDisk(String n, String a, int t)
         artistname = n; //Stores the 1st argument passed after "new Dates" into day
         albumname = a; //Stores the 2nd argument passed after "new Dates" into month
         numberoftracks = t; //Stores the 3rd argument passed after "new Dates" into year
         //When called from the main method, prints the contents of
         //artistname, albumname and numberoftracks on to the screen.
         public void printCompactDisk ()
                   String output = "\n " + artistname + "\n " + albumname + "\n " + numberoftracks;
                   System.out.println(output);
    }

    //by Andrei Souchinski
    //Mini Project: CD Collection Database
    //Designed for a grade F
    //Defining new class of objects to represent CD database entries.
    //A database entry consists of the artist name, the album name and number of tracks.
    //A single entry can be entered by the user typing the details in and the entry can be printed out.
    import javax.swing.*;
    import java.util.*;
    public class MiniProject
         public static void main (String[] args)     
              System.out.println("\tCD Collection Database\n");
              System.out.println("1. Add new Compact Disk to the Database");
              System.out.println("2. Print out current database entries");
              System.out.println("3. Quit\n");          
                theMenu();
         public static void theMenu()
              String menu;
              menu = JOptionPane.showInputDialog("What would you like to do?");
              if (menu.equals ("3"))
                   JOptionPane.showMessageDialog(null, "Thank You For Using our Service! \nGoodbye!");
                   System.exit(0);     
              if (menu.equals ("2"))
              if (menu.equals ("1"))
              addNewEntry();
              else
                   JOptionPane.showMessageDialog(null, "Please select your choice form the menu");
                   theMenu();
         public static void addNewEntry()
                   CompactDisk [] array = new CompactDisk[20];
                   int i = 0;
                   array.artistname = (JOptionPane.showInputDialog("Please enter the name of the Artist"));
                   array[i].albumname = (JOptionPane.showInputDialog("Please enter the name of the Album"));
                   array[i].numberoftracks = (Integer.parseInt (JOptionPane.showInputDialog("Please enter the number of tracks on this album")));
    //A Compact Disk entry consists of three attributes: artist name, album and number of tracks
    class CompactDisk
         public String artistname; //Instance variables for artistname, albumname and numberoftracks.
         public String albumname;
         public int numberoftracks;
         public CompactDisk(String n, String a, int t)
         artistname = n; //Stores the 1st argument passed after "new Dates" into day
         albumname = a; //Stores the 2nd argument passed after "new Dates" into month
         numberoftracks = t; //Stores the 3rd argument passed after "new Dates" into year
         //When called from the main method, prints the contents of
         //artistname, albumname and numberoftracks on to the screen.
         public void printCompactDisk ()
                   String output = "\n " + artistname + "\n " + albumname + "\n " + numberoftracks;
                   System.out.println(output);
    I've edited the code, itcompiles, but gives an error when i ran it..:(

  • Passing an array as parameter from java (java controls) to stored procedure

    Hi,
    I'm using java controls (BEA Weblogic Workshop 8.1) to call a stored procedure and send an array as a parameter to the stored procedure from java. The following code below throws an exception "Fail to convert to internal representation".
    Java code
    import com.bea.control.DatabaseControl.SQLParameter;
    // Here i create the java array
    int[] javaArray={12,13,14};
    //The code below is used to create the oracle sql array for the procedure
    SQLParameter[] params = new SQLParameter[1];
    Object obj0=javaArray;
    params[0] = new SQLParameter(obj0, oracle.jdbc.OracleTypes.ARRAY, SQLParameter.IN);
    // the code below calls the testFunc method in OJDBCtrl.jcx file
    String succ= dbControl.testFunc(params);
    OJDBCtrl.jcx
    * @jc:sql statement="call CMNT_TST_PROC(?))"
    String testFunc(SQLParameter[] param);
    The stored procedure used:
    TYPE SL_tab IS TABLE OF number INDEX BY PLS_INTEGER;
    Procedure cmnt_tst_proc (cmnt_tst sl_tab);
    Procedure cmnt_tst_proc (cmnt_tst sl_tab) is
    BEGIN
    dbms_output.put_line('Hello');
    END;
    I am getting the following exception
    Failure=java.sql.SQLException: Fail to convert to internal representation: [I@438af4 [ServiceException]>
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
    at oracle.jdbc.driver.DatabaseError.check_error(DatabaseError.java:861)
    at oracle.sql.ARRAY.toARRAY(ARRAY.java:210)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7768)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7449)
    at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7837)
    at oracle.jdbc.driver.OracleCallableStatement.setObject(OracleCallableStatement.java:4587)
    at weblogic.jdbc.wrapper.PreparedStatement.setObject(PreparedStatement.java:244)
    at com.bea.wlw.runtime.core.control.DatabaseControlImpl._setParameter(DatabaseControlImpl.jcs:1886)
    at com.bea.wlw.runtime.core.control.DatabaseControlImpl.getStatement_v2(DatabaseControlImpl.jcs:1732)
    at com.bea.wlw.runtime.core.control.DatabaseControlImpl.invoke(DatabaseControlImpl.jcs:2591)
    at com.bea.wlw.runtime.core.dispatcher.DispMethod.invoke(DispMethod.java:377)
    at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:433)
    at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:406)
    at com.bea.wlw.runtime.core.container.Invocable.invoke(Invocable.java:249)
    at com.bea.wlw.runtime.jcs.container.JcsContainer.invoke(JcsContainer.java:85)
    at com.bea.wlw.runtime.core.bean.BaseContainerBean.invokeBase(BaseContainerBean.java:224)
    at com.bea.wlw.runtime.core.bean.SLSBContainerBean.invoke(SLSBContainerBean.java:109)
    at com.bea.wlwgen.StatelessContainer_ly05hg_ELOImpl.invoke(StatelessContainer_ly05hg_ELOImpl.java:153)
    Can you please let me know, what i'm doing wrong and how i can pass an array to a procedure/function using java controls.
    Any help will be highly appreciated.
    Edited by: user12671762 on Feb 24, 2010 5:03 AM
    Edited by: user9211663 on Feb 24, 2010 9:04 PM

    Thanks Michael.
    Here's the final code that i used, this might be helpful for those who face this problem
    Java Code
    // Following code gets the connection object
    InitialContext ctx = new InitialContext();
    dataSource = (DataSource)ctx.lookup("<DataSourceName>");
    conn=dataSource.getConnection();
    // Following code is used to create the array type from java
    String query="CREATE OR REPLACE TYPE STR_ARRAY AS VARRAY(3) OF NUMBER";
    dbControl.runTypeQuery(query);
    // Following code is used to obtain the oracle sql array as SQLParameter
    ArrayDescriptor desc = ArrayDescriptor.createDescriptor("<schemaName>.STR_ARRAY", conn);
    Object[] elements = new Object[3];
    elements[0] = new Integer(12);
    elements[1] = new Integer(13);
    elements[2] = new Integer(14);
    oracle.sql.ARRAY newArray = new oracle.sql.ARRAY( desc, conn, elements);
    SQLParameter[] params = new SQLParameter[1];
    params[0] = new SQLParameter(newArray, oracle.jdbc.OracleTypes.ARRAY, SQLParameter.IN);
    String succ= dbControl.testFunc(params);

  • Trying to pass Oracle array/object type to Java

    I have a Java class with two inner classes that are loaded into Oracle:
    public class PDFJ
        public static class TextObject
            public String font_name;
            public int font_size;
            public String font_style;
            public String text_string;
        public static class ColumnObject
            public int left_pos;
            public int right_pos;
            public int top_pos;
            public int bottom_pos;
            public int leading;
            public TextObject[] column_texts;
    }I have object types in Oracle as such that bind to the Java classes:
    CREATE OR REPLACE TYPE "PROGRAMMER"."PDFJ_TEXT" AS OBJECT
    EXTERNAL NAME 'PDFJ$TextObject'
    LANGUAGE JAVA
    USING SQLData(
      "FONT_NAME" VARCHAR2(25) EXTERNAL NAME 'font_name',
      "FONT_SIZE" NUMBER EXTERNAL NAME 'font_size',
      "FONT_STYLE" VARCHAR2(1) EXTERNAL NAME 'font_style',
      "TEXT_STRING" VARCHAR2(4000) EXTERNAL NAME 'text_string'
    CREATE OR REPLACE TYPE "PROGRAMMER"."PDFJ_TEXT_ARRAY" AS
      TABLE OF "PROGRAMMER"."PDFJ_TEXT";
    CREATE OR REPLACE TYPE "PROGRAMMER"."PDFJ_COLUMN" AS OBJECT
    EXTERNAL NAME 'PDFJ$ColumnObject'
    LANGUAGE JAVA
    USING SQLData(
      "LEFT_POS" NUMBER EXTERNAL NAME 'left_pos',
      "RIGHT_POS" NUMBER EXTERNAL NAME 'right_pos',
      "TOP_POS" NUMBER EXTERNAL NAME 'top_pos',
      "BOTTOM_POS" NUMBER EXTERNAL NAME 'bottom_pos',
      "LEADING" NUMBER EXTERNAL NAME 'leading',
      "COLUMN_TEXTS" "PROGRAMMER"."PDFJ_TEXT_ARRAY" EXTERNAL NAME 'column_texts'
    CREATE OR REPLACE TYPE "PROGRAMMER"."PDFJ_COLUMN_ARRAY" AS
        TABLE OF "PROGRAMMER"."PDFJ_COLUMN";
    /I successfully (as far as I know) build a PDFJ_COLUMN_ARRAY object in a PL/SQL procedure. The PDFJ_COLUMN_ARRAY contains PDFJ_COLUMN objects; each of those objects contains a PDFJ_TEXT_ARRAY of PDFJ_TEXT objects (Example: pdf_column_array(i).pdf_text_array(i).text_string := 'something';). In this procedure, I pass this PDFJ_COLUMN_ARRAY as a parameter to a Java function. I assume the Java function parameter is supposed to be a oracle.sql.ARRAY object.
    I cannot figure out how to decompose this generic ARRAY object into a ColumnObject[] array. I also tried Googling and searching the forums, but I can't figure out matching search criteria. I was wondering if anyone here knows anything about passing user-defined Oracle type objects to a Java function and retrieving the user-defined Java class equivalents that they are supposedly mapped to--especially a user-defined array type of user-defined object types containing another user-defined array type of user-defined object types.

    Ok. I will try asking on the JDBC forum. So, don't
    flame me for cross-posting. :PWe won't, if over there you just post basically a
    link to this one.
    sigh Guess what, he did it the flame-deserving way. It's crossposted at:
    http://forum.java.sun.com/thread.jspa?threadID=602805
    <flame level="mild">Never ceases to amaze me how people don't think that posting a duplicate rather than a simple link isn't wasteful, as people could end up answering in both of them, not seeing each other's answers</flame>

Maybe you are looking for

  • Error while uploading data in LT03?

    Dear All, I am uploading data in LT03 transaction and I am getting an error message 'System cannot find source storage bin'. I am using BAPI  'L_TO_CREATE_DN'. Even same error  I am getting in recording. This is happened in the case of Partial delive

  • Installments - first installment with changing value

    Hello Experts, My customer requires to have such an installment scenario. Let's say we have Material A for $1000 it is sold in 4 installments. Installement 1 - $250 Installement 2 - $250 Installement 3 - $250 Installement 4 - $250 that's pretty easy

  • ERMS: Inbound mails are not displaying in Agent inbox from IC web

    Hi Experts,                    We are implementing ERMS solution.. in CRM 2007 system. I am not able find the inbound mails in Agent inbox. I have done the below settings.. 1. Mail settings has done by BASIS team and whenever i sent a mail to ( cust@

  • GET_BUSINESS_SYSTEM_ERROR  , when Test the OB interface from R3  for proxy?

    Hi friends ,                   In my scenario ABAP Proxy to file. First i have activated the proxy . While i was  trying to <b>Test Interface (F8)</b>  BUTTON .    It is showing the Following Message            <b> 1. My sm59 's TCP/IP Connection tes

  • How to get the gross weight of the material after packing in delivery ?

    Hello, We need to print the gross weight of the material after packing which includes packing material weight and target quantity weight for each material in the delivery. From which table the gross weight of the material after packing can be retriev