Arbitrary number of parameters

I try to call a method defined to accept an arbitrary number of parameters, in particular in the following piece of code:
String catalogPath = "/path/to/catalog";
Constructor constr = resolverClass.getConstructor(
  new Class[] {CatalogManager.class});
Object obj = constr.newInstance(catalogPath);where the method newInstance (see java.lang.reflect.Constructor) is declared as follows:
public T newInstance(Object... initargs)
              throws InstantiationException,
                     IllegalAccessException,
                     IllegalArgumentException,
                     InvocationTargetExceptionHowever, this piece of code is rejected (method not applicable to String). Casting the String into an Object returns the same comment, now for Object. Putting the String into an array and passing that array as a parameter is compiled without any problems but then throws an IllegalArgumentException with the message "type mismatch".
What am I doing wrong here? Or is that in fact a compiling problem? (I'm using Java SE 1.6.0_01).
Dieter

Dear endasil,
many thanks for your helpful comments! In fact, I was slightly confused about my own writing after reading your comment!-)
What I really wanted to do was the following:
CatalogManager mgr = new CatalogManager(path);
CatalogResolver res = new CatalogResolver(mgr);In the meantime, I have found a way to avoid Reflection so the problem has gone for the moment. But I tried to rewrite the snippet above correctly, and - at least - there are no compiling problems any more:
      String catalogPath = "/Dieter/JAVA_Beispiele/XSLT/build";
      CatalogManager cm = new CatalogManager(catalogPath);
      // get a CatalogResolver instance and preset its CatalogManager
      Class resolverClass = loader.loadClass(className);
      Constructor constr = resolverClass.getConstructor(
         new Class[] {CatalogManager.class});
      Object[] args = new Object[] {cm};
      Object obj = constr.newInstance(args);However, I have to explicitly use an array; just putting cm as a single argument instead of args is not accepted by the compiler!
Many thanks for your (eye opening!) help!
profos

Similar Messages

  • How do I fix the format of plot lines for an arbitrary number of sets of data plotted on the same x-y graph?

    I have written a VI to control an LCR meter and perform sweep functions. I have two x-y graphs on my front panel (one for each of 2 measured parameters). The VI is designed with a button to take a measurement, plot the data, and then wait for another event (like write data, clear plot, or measure again). The user can take simultaneous measurements and these are plotted on top of the data already there in the same x-y graphs (using an array of clusters with shift registers). There is no limit on how many sets of data can be on the x-y graph. 
    Now, my issue is in formatting the plot lines (color, thickness, marker type). I can fix the first plot line by adjusting the parameters of the x-y graph. However, I also want to control the format of all consecutive plot lines. How can I do this for an arbitrary number of lines? The main thing I want to do is to have all of them show the square marker type (the default is no marker type, just a line). 
    Thanks!

    Hi maximum23,
    You can use properties of plot to format the plot lines. You just have to select Active plot using property and then select color and line width etc..
    You can define color and width etc parameter by asking user or you can just make them default.
    Gaurav k
    CLD Certified !!!!!
    Do not forget to Mark solution and to give Kudo if problem is solved.

  • Error executing CFC. Parameter index out of range (2 number of parameters, which is 1)

    Hi,
    My CFC component is defined as:
    <cffunction name="updateNote" output="false" access="remote"  returntype="void" >
         <cfargument name="notedetails" required="true" type="string" >
         <cfargument name="notename" required="true" type="string" />
         <cfquery name="qupdateNote" datasource="notes_db">
               UPDATE
                   notes
               SET
                   notes.notedetails=<CFQUERYPARAM CFSQLTYPE="CF_SQL_VARCHAR" VALUE="#ARGUMENTS.notedetails#">,
               WHERE
                   notename="<CFQUERYPARAM CFSQLTYPE="CF_SQL_VARCHAR" VALUE="#ARGUMENTS.notename#">"
        </cfquery>
    </cffunction>
    In Flash builder when I test the operation I get this error:
    "There was an error while invoking the operation. Check  your server settings and try invoking the operation again.
    Reason:  Server error Unable to invoke CFC - Error Executing Database Query. Parameter  index out of range (2 > number of parameters, which is 1)."
    Im really quessing that this is something small but right now its causing me to pull my hair out of my head!! Argg. Tried a bunch of things but I know thik im stuck.
    Help would be very very appreciated.
    Thanks

    Create test.cfm along these lines:
    <cfset myObj = createObject("component", "dotted.path.to.cfc.file")>
    <cfset myResult = myObj.myMethod(arg=value1, etc)>
    <cfdump var="#myResult#">
    Or, really, you could just browse to this:
    http://your.domain/path/to/your.cfc?method=yourMethod&arg1=value1 [etc]
    Although I dunno which of those two approachs will give you a better error message (indeed, it might be the same).
    Try both.
    Adam

  • Is there a max number of parameters that can be passed to a C function in test stand v. 1.0.1

    I have had an issue with test stand version 1.0.1 (yes, I know; it's quite old) and calling a C function thru an action step. when I call this function with 18 parameters, it seems to hang. I have called a function with 16 and it seems to work. Is this a limit of the software? I am calling the function from a windows DLL that we've created. When I try to pull the function from the dll into test stand I also get a { error...but I get that in the other function's call and it seems to work fine. Any ideas?

    ok, upon re-reading what I posted I can clearly see your confusion. haha. I think there are two separate issues.
    1) Are there a maximum number of parameters one can use when calling a C function from a DLL? Yes, i'm trying to call a C function from test stand.
    2) when I select the "module" tab, and select which DLL contains my function, the prototype has no information associated with it (by clicking the reload prototype button). I'm not sure why, as I'm using a declspec to send the function information out of the dll, but that's another topic. So I click on the source file tab and point the window to the .cpp of my function (within the DLL's project workspace) and when it begins to parse the file, I get an error about mis-matched curly brackets and if I wish to continue, and skip the rest of the parsing.
    I click "OK" and when I go back to the module tab, I am able to see all my functions, along with the parameters in the drop down menu below. I fill in all the parameters and everything looks ok; no syntax errors, or anything else seemingly suspicious. I then run my test stand code and when I get to the step which calls this function, the system hangs and cannot proceed.
    Any thoughts as to what might cause these issues? 

  • Passing Variable Number of Parameters to Cobol Stored Procedure

    Hi. I have a web front end that needs to access several different tables via Cobol stored procedures. It seems simple enough to call the stored procedures straight away (DAO Pattern perhaps?) but my boss is insistent on having an intermediate Cobol program that decides which table to access. I think he at a bigger picture than I can see.
    The problem lies in the number of parameters that need to be passed to the stored procedures; some need 3, others needs 5, a few need 4. The only two solutions that I can think of are to pass EVERYTHING (we're talking 50 parameters or so) to the intermediate stored procedure and then pulling only what is needed from that data set to access the desired table. Solution number two involves passing everything to a temp table and then pulling what is needed from it. The former solution seems a little cleaner but still involves passing a lot of parameters. If Cobol could handle some sort of dynamic memory allocation (Vector) there seems to be a possible solution there. Though, as far as I know, that isn't possible.
    Any ideas are much appreciated.
    Thanks in advance,
    Chris

    Hi Saurabh,
    The method in which stored procedures are called on form submit is something as follows.
    Let us take your scenario of a form which has multiple checkboxes and a submit button. On clicking the submit button, this form data is submitted using either get or post. The form's submit action invokes a procedure.
    The HTML form code will look something like this..
    htp.formOpen( curl => 'URL /myProcedure',
    cmethod => 'post' );
    htp.formCheckbox( cname => 'myCheckbox'
    cvalue => 'A');
    htp.formCheckbox( cname => 'myCheckbox'
    cvalue => 'B');
    htp.formCheckbox( cname => 'myCheckbox'
    cvalue => 'C');
    htp.formSubmit( cname => 'myButton',
    cvalue => 'OK');
    Now, whenever the submit button is clicked, all these form values are passed to our stored procedure 'myProcedure'.
    "myProcedure" looks something like this.
    procedure myProcedure
    myCheckbox IN sys.owa_util.vc_arr,
    myButton IN VARCHAR2
    is
    begin
    end myProcedure;
    The point to be noted here is that the name of the variable being passed in the procedure is the same as the name of the HTML element being created in the HTML form. So, there is a direct mapping between the elements in the HTML form and the procedure parameters.
    Another noteworthy point is that since you have multiple checkboxes in your HTML form, it is impractical to name all the checkboxes differently and then pass those many parameters to your procedure (Imagine a scenario where there are a hundred check-boxes in an HTML form!). So portal allows you to give the same name (cname) to all the checkboxes in your HTML form, and if multiple checkboxes are checked, it will return all the checkbox values in an array (Note the usage of "myCheckbox IN sys.owa_util.vc_arr" in myProcedure).
    You can check out this link for more information.
    Re: retrieving data from fields
    Thanks,
    Ashish.

  • Variable number of parameters in a procedure

    Hello !
    I have a form in a procedure with dynamic inputs type "checkbox" (one checkbox by record of a table).
    The action of the form is another procedure. There is a variable number of parameters (depending on checked inputs).
    How can I do for retreiving these variable data within a single variable in my second procedure ?
    Thanks for help and sample
    null

    What u can do is use Javascript and pass all the selected checkbox Ids as a dilimited string..which u can read in second procedure and can perform appropriate action. for example if you have check box named as chk1,chk2,chk3,chk4 n so on..
    now if chk1,chk3,chk4 are checked then pass this string in the hidden field "1|3|4"which is a |(pipe) delimited string..

  • How to create a dynamic query in which I can vary number of parameters

    I am writing a JDBC connector. I want to write a dynamic query in that. The query should be able to proceed variable number of parameters and also in the where clause the and/or/like parameters I want to place dynamically.
    I can't write store procedures as we just have read only access to Database so I want to do it through query only.
    Please help me out in doing that as I am not able to proceed further without it ...

    Hi,
    Have a luk at :placeholder for IN condition in database adapter

  • PreparedStatement - unknown number of parameters

    Help!
    I have to use PreparedStatement to access an oracle database. This statement should be able to handle a number of values for one parameter. For example the parameter is area and there is a number of counties the user can choose...
    So i have a query statment like
    select population from populatn where area IN('BEAVER', 'CACHE'......)
    Here how do I use preparedstatement?
    Sue

    Yeah, that's always what they mean when they ask the
    question. The answer is still no.right. when you have a variable number of parameters than you don't have a prepared statement anymore.
    however if you want to get information about a prepared statement's parameters you can use getParameterMetaData method of PreparedStatement new in 1.4.

  • Variable number of parameters to procedure

    I have a requirement to pass variable number of parameters for an attribute, to a stored procedure.
    example:
    procedure getSum(country_code IN varchar2, sum OUT number)
    Inside the procedure, I am currently
    writing SQL as
    where eligible_code in (country_code).
    This is ok when I pass just one code.
    However I need to deal with n number of
    country codes at a given time.
    i.e. if I want to pass 3 country codes
    as a concatinated string say "A-B-C"
    where A, B, C are 3 different codes,
    how do I decode them into a
    meaning full
    where eligible_code in ('A', 'B', 'C')
    Or is there any other way of dealing
    with this kind of situation.
    The bottom line is I must have a stored
    procedure, that takes parameter(s).
    Any input/suggestion is highly appreciated.

    Please try the following, substituting the appropriate table name for your_table and the appropriate column name for eligible_code, then see if you can incorporate some of it into your procedure. Please let me know if it works for you or not.
    SQL> EDIT getsum
    CREATE OR REPLACE PROCEDURE getsum
    (country_code IN VARCHAR2,
    p_sum OUT NUMBER)
    AS
    v_country_codes VARCHAR2 (300);
    v_sum NUMBER := 0;
    v_sql_statement VARCHAR2 (3000);
    v_sql_syntax VARCHAR2 (30000);
    cursor_name INTEGER;
    ignore INTEGER;
    BEGIN
    v_country_codes := REPLACE (country_code, '-', ''',''');
    v_sql_statement := ' SELECT COUNT (*)
    INTO :v_sum
    FROM your_table
    WHERE eligible_code IN (''' &#0124; &#0124; v_country_codes &#0124; &#0124; ''');';
    v_sql_syntax := 'BEGIN '&#0124; &#0124; v_sql_statement &#0124; &#0124;' END;';
    cursor_name := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE (cursor_name, v_sql_syntax, DBMS_SQL.NATIVE);
    DBMS_SQL.BIND_VARIABLE (cursor_name, ':v_sum', v_sum);
    ignore := DBMS_SQL.EXECUTE (cursor_name);
    DBMS_SQL.VARIABLE_VALUE (cursor_name, ':v_sum', v_sum);
    DBMS_SQL.CLOSE_CURSOR (cursor_name);
    p_sum := v_sum;
    END getsum;
    Save the file.
    SQL> START getsum
    Procedure created.
    SQL> VARIABLE g_sum NUMBER
    SQL> EXEC getsum ('A-B-C', :g_sum)
    PL/SQL procedure successfully completed.
    SQL> PRINT g_sum
    G_SUM
    3
    null

  • Argument error; the number of columns does not equal the number of parameters.

    I am using the Database Toolkit (Enterprise Connectivity) to check for a network connection and then send information from a local database to a SQL database on the network if needed.  In development of the code I continue to receive Error 1 and the Possible Reason(s) is "Argument error; the number of columns does not equal the number of parameters."  I am using the DBToolsSelectData.VI to retrieve data from the local MDB file and the DBToolsInsertData.VI to write it to the SQL file.  The collection of the data from the MDB file is successful and the connection and validation of the table and columns in the SQL file is also successful.  The error occurs when the Insert VI tries to build the query.  The number of columns being written (attempted) does match the number of columns in the data, they are both 16 string arrays.

    Ok, it's taken a bit, and I have a solution! It took a while to figure out what the DCT is doing, but it seems to be working now.
    The reason for the original error is that you were passing into the insert subVI an array of variants - which the input to the VI coerced into a single variant. You were getting the error because as far as the insert VI was concerned you were only passing it a single data value. The way to get around that was to create a cluster with one element for each column value, convert the cluster to a variant and pass the result to the insert VI - see attachment.
    In terms of the other modifications, I made a copy of the endurance.mdb file, emptied it and used it as the destination for the copy.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps
    Attachments:
    NetworkCheck.vi ‏49 KB

  • Undefined number of parameters in a function

    Hi!
    Recenlty I've seen in somewhere that new verions of java enable functions to recieve an undefined number of parameters; something like (see the ...)
    public static void createList(int p1, ...){
    }But I don't know where can I find information about this, and I have not be able to find it anywhere.
    Thanks in advance.

    VarArgs

  • [ETL]How to transform a Source model into an arbitrary number of target models ?

    Hi all,
    I need to know how to transform a source model into an arbitrary number of target models which conforms to different target metamodels using ETL ? Is there any examples that can help me ?
    Thank you
    Mana

    Hi Antonio,
    Actully I mean the number of metamodels are known.For example, assume that there are two known metamodels in the target side, the first one is the target metamodel, and the second one is the trace metamodel .
    I would like to see an example of ETL transformation that run on a source model and generate the target model and the trace model as well. This statement is part of the chapter 5 of the ebook which says "it is often essential to be able to access/update additional models during a transformation (such as trace or configuration models). Building on the facilities provided by EMC and EOL, ETL enables specification of transformations that can transform an arbitrary number of source models into an arbitrary number of target models."
    could you please explain this more for me or provide me with an example.
    Thank you
    Mana

  • Passing large number of parameters

    In chapter 6 of the reports 6i documentation it states that one of the advantages of using a ref cursor is to "avoid the use of lexical parameters in your reports". I am not clear how it does this. Can anyone explain how this would work?
    In my application, I would like to print an exception report (ie use run_report) when an item in the base report exceeds a threshold amount. I would rather not pass all the subtotal values, as that would require passing a large number of parameters to the exception report. I can do it, but it seems like there should be an easier way. Passing a parameter of type RECORD would do it, but isn't allowed, right?
    null

    1. In some cases, you can avoid the use of lexical parameters in your reports
    with "static" ref cursor.
    Example for "static" ref cursor:
    1.1 Stored package
    CREATE OR REPLACE PACKAGE report_static IS
    TYPE type_ref_cur_sta IS REF CURSOR RETURN dept%ROWTYPE;
    FUNCTION func_sta (p_order_by VARCHAR2) RETURN type_ref_cur_sta;
    END;
    CREATE OR REPLACE PACKAGE BODY report_static IS
    FUNCTION func_sta (p_order_by VARCHAR2) RETURN type_ref_cur_sta IS
    ref_cur_sta type_ref_cur_sta;
    BEGIN
    IF p_order_by = 'dname' THEN
    OPEN ref_cur_sta FOR
    SELECT * FROM dept ORDER BY dname;
    ELSE
    OPEN ref_cur_sta FOR
    SELECT * FROM dept ORDER BY deptno;
    END IF;
    RETURN ref_cur_sta;
    END;
    END;
    1.2 Query PL/SQL in Reports
    function QR_1RefCurQuery return report_static.type_ref_cur_sta is
    begin
    return report_static.func_sta (:p_order_by);
    end;
    2. But if you need (for example) dynamic where, you (practically)
    can't use "static" ref cursor. In this case, you can use "dynamic" ref cursor
    (available from Oracle 8.1.5).
    Example for "dynamic" ref cursor (note that Reports need
    "static" ref cursor type for building Report Layout):
    2.1 Stored package
    CREATE OR REPLACE PACKAGE report_dynamic IS
    TYPE type_ref_cur_sta IS REF CURSOR RETURN dept%ROWTYPE; -- for Report Layout only
    TYPE type_ref_cur_dyn IS REF CURSOR;
    FUNCTION func_dyn (p_where VARCHAR2) RETURN type_ref_cur_dyn;
    END;
    CREATE OR REPLACE PACKAGE BODY report_dynamic IS
    FUNCTION func_dyn (p_where VARCHAR2) RETURN type_ref_cur_dyn IS
    ref_cur_dyn type_ref_cur_dyn;
    BEGIN
    OPEN ref_cur_dyn FOR
    'SELECT * FROM dept WHERE ' &#0124; &#0124; NVL (p_where, '1 = 1');
    RETURN ref_cur_dyn;
    END;
    END;
    2.2 Query PL/SQL in Reports
    function QR_1RefCurQuery return report_dynamic.type_ref_cur_sta is
    begin
    return report_dynamic.func_dyn (:p_where);
    end;
    Regards

  • Sequence Parameters: Can I use variable number of parameters?

    Can I create a sequence that has a variable number of parameters?
    If not, Can I pass an array of objects as a paramater?
    In the sequence code:
    for (i=0; i< Parameters.Params.GetNumElements(); i++) {
    object o = Parameters.Params[i];
    // Do something with o
    In the above case, can I call the sequence by putting a "new object[] {(double(2.0)}" as the parameter value?
    For example:
    call VarParams
    Params = PropertyObject.SetPropertyObject (Engine.NewPropertyObject (valueType, asArray, typeName, options))

    Not only can you pass an array of different sizes but you can also make a parameter an empty container and fill it with any container.  The problem is you have to access it correctly within the subsequence.  I can see a practical use for the Array but not really for the container.
    Your last question regarding creating params dynamically: I would have a local variable that is in the Value for the parameter and then just change the local to what you want in the PreExpression.
    Hope this helps,
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • Arbitrary Number Generated before Sales Order Document number is Generated

    I want to know which is the arbitrary number generated before the sales Order Document number is created. In which table the arbitrary number is stored?
    The Exit which triggers the arbitrary number in the transaction VA01?

    Hi
    You get the Arbitrary number throug the FM NUMBER_GET_NEXT.
    interne Nummernvergabe
            data: da_rc like inri-returncode.
            call function 'NUMBER_GET_NEXT'
              exporting
                nr_range_nr = da_numki
                object      = 'RV_BELEG'
              importing
                returncode  = da_rc
                number      = vbak-vbeln.
    And regarding userexit, there is
    perform userexit_number_range using da_numki statement in include MV45AF0B_BELEG_SICHERN.
    Regards
    Raj

Maybe you are looking for