How to invoke a class at run-time for primitive data types?

Hi,
I am trying to invoke classes at run-time.
I am using Class.forName("className") for that where the "className" is also obtained at run-time .
The problem I am getting is when the "className" is "int" or "char" etc. the call to Class.forName("int") etc. fails giving ClassNotFound error. It works fine for "className" is "java.lang.String" or "java.lang.Integer" etc.
How can I correct this?
thanks in advance-
kg

Hi,
Thanks all for the valuable inputs.
I have created a hashtable of primitive data types in the form of "int" as key and "Integer.TYPE" as the object in that element of the hashtable.
Now there is another problem I am facing and that is of 'Casting at run-time'.
Problem is there when the Database type is 'NUMBER' which returns me a "java.lang.BigDecimal" when I do a ResultSet.getObject("XXX") for that whereas the method in the javabean expects an "int" type.
This causes "java.lang.IllegalArgumentException: argument type mismatch"
So I want to cast it at runtime. How can I do it?
Here is the code I am trying (which generates the above exception)
public static void setBeanField(Class pCls,Object pObj,String pMethodName ,Object pColumnValue,Class
pColumnTypeClass){
try{
if(pColumnValue!=null){
Class[] paramTypes = new Class[]{pColumnTypeClass};
Object[] args = new Object[]{pColumnValue};
Method meth = pCls.getMethod(pMethodName,paramTypes);
meth.invoke(pObj,args);
}catch(Exception e){
System.out.println("Exception in TestInrospection.setBeanField " + e);
thanks in advance-
kg

Similar Messages

  • How can I have both date and time for a Date type variable?

    If I have a Date type variable: Date today=new Date(), Is it possible to also give the current time to "today" but still keep the type as Date?
    I mean , for exmaple I want to store this "today" to database as Date type, and the value in database is "2007-05-05 13:30:13". I do not want to use SimpleDateFormat to do that, because I want to use Date type not String. Is that possible? how to implement this?

    I'd say he means you should use Timestamp to store
    the time value, because that's what it's there for.
    Because java.sql.Date is defined not to store a
    time value.Correct. The OP should read the Javadoc for java.sql.Timestamp.

  • Run time for a query

    Hello all,
    Can you please tell me how can I see the total running time for a query?
    What other transactions besides ST03 and RSRT with statistics on?
    Points will be assigned
    Thanks
    Ramona

    Hi........
    You can use ST03N -> BW System Load
    Depending on the time frame you select, you get historical data or
    current data.
    To get to a specific query you need to drill down using the InfoCube
    name
    Use Aggregation Query to get more runtime information about a
    single query. Use tab All data to get to the details.
    (DB, OLAP, and Frontend time, plus Select/ Transferred records,
    plus number of cells and formats)
    Also You can get it in RSRT,RSRTQ...
    WE07  IDoc statistics 
    DB20  Update DB Statistics 
    Regards,
    Debjani........
    Edited by: Debjani  Mukherjee on Sep 25, 2008 2:42 PM

  • How to create transparent image at run-time?

    How to create transparent image at run-time? I mean I want to create a (new) transparent image1, then show other (loaded) transparent image2 to image1, then show image1 to a DC. The problem is - image1 has non-transparent background...

    i'm not sure, but you can set the alpha value to 0 in all pixels which are 'in' the background..
    greetz
    chris

  • How to pass column name at run time in function.

    how to pass column name at run time in function as parameter.
    thank in advance
    pramod patel

    Hello,
    Using dynamic sql you can pass column name to function. well I am not getting what you really want to do ? Please write in more detail. By the way I am providing one example here. see it uses dynamic sql.
    Create or replace function fun_updtest (p_columnname_varchar2 in varchar2,
    p_value_number in number)
    return number is
    v_stmt varchar2(500);
    begin
    v_stmt := 'update emp
    set '||p_columnname_varchar2||' = '||to_char(p_value_number)||'
              where empno = 7369';
    execute immediate v_stmt;
    return 0;
    commit;
    end;
    call to this function can be like this..
    declare
    v_number               number;
    begin
    v_number := fun_updtest('SAL',5000);
    end;
    Adinath Kamode

  • How to call abap proxy at run time?

    hello frnds,
    i m working on a scenario in which whenever Invoice is saved in SAP R/3 at that time same data should go to Oracle DB. i m using ABAP proxy on SAP R/3 side and JDBC receicver adapter on oracle side of XI.
    so to post data i need to call ABAP Proxy whenever invoice is saved.. i have tried to find out save event for invoice but not able to get... can anybody tell me the solution that how i can call proxy at run time?
    thanx in advance.
    Regards,
    Hetal.....

    Hi Audumbar,
    Check these ...
    /people/vijaya.kumari2/blog/2006/01/26/how-do-you-activate-abap-proxies
    /people/siva.maranani/blog/2005/04/03/abap-server-proxies
    /people/vanita.thareja2/blog/2006/05/23/bpm-sending-message-asynchronously-and-getting-the-response-from-synchronous-system-using-abap-proxies
    /people/ravikumar.allampallam/blog/2005/03/14/abap-proxies-in-xiclient-proxy
    cheers,
    Prashanth
    P.S Please mark helpful answers

  • How to change the view criteria at run time for af:query

    Hi,
    I've a usecase where I need to change the view criteria of the af:query at run time.
    Use case:
    =======
    1) Consider a check box (Show Emps Under Dept 10) in the query panel when user selects and clicks 'Search' button should show the employees under dept 10. If user searches without selecting the check box, the results should show all the employees in all the departments.
    2) I need to have a check box always in the query panel. Its mandatory.
    The way I implemented:
    ==============
    1) Created a transient variable 'Show Emps Under Dept 10' in the EmployeeVO and also created a bind variable bind_DeptNo.
    2) Create a view criteria 'AllEmployees' which has only the transient attribute as the view criteria item and whose value set to 'false' by default.
    3) Created another view criteria 'EmpUnderDept' which has 'DepartmentId' as the view criteria item and whose value set to the bind variable 'bind_DeptNo'.
    4) Dropped the view criteria 'EmpUnderDept' as the 'af:query' panel in the jspx page.
    5) Overridden the queryListener as '#{EmpBean.empSearch}'
    6) Has the below code in the empSearch method as below. When user selects the check box, applying the other criteria 'EmpUnderDept' and setting the bind variable to '10'.
    public void empSearch(QueryEvent queryEvent) {
    // Add event code here...
    QueryDescriptor queryDesc = (QueryDescriptor) queryEvent.getDescriptor();
    ConjunctionCriterion conCrit = queryDesc.getConjunctionCriterion();
    List<Criterion> criterionList = conCrit.getCriterionList();
    List criterionValues = new ArrayList();
    Object criteriaValue = null;
    int criteriaNo = 0;
    DCBindingContainer bc = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    FacesContext facesContext = FacesContext.getCurrentInstance();
    for (Criterion criterion : criterionList) {
    AttributeDescriptor attrDescriptor = ((AttributeCriterion)criterion).getAttribute();
    System.out.println("============== attrDescriptor.getName() =================== " + attrDescriptor.getName());
    criteriaValue = ((AttributeCriterion)criterion).getValues().get(0);
    if(criteriaNo==0) {
    Boolean val = (Boolean) ((AttributeCriterion)criterion).getValues().get(0);
    if (val.equals(true)) {
    OperationBinding method = (OperationBinding) ADFUtil.findOperation("ExecuteWithParams");
    if(method!=null) {
    Map params = method.getParamsMap();
    //params.put(key, value)
    method.getParamsMap().put("bind_DeptId", 10L);
    method.execute();
    ADFUtil.invokeMethodExpression( "#{bindings.EmpUnderDeptCriteiaQuery.processQuery}", queryEvent);
    } else {
    //ADFUtil.invokeEL("#{bindings.ExecuteWithParams.execute}");
    ADFUtil.invokeMethodExpression( "#{bindings.AllEmployeesCriteriaQuery.processQuery}", queryEvent);
    But this approach is not working and its always showing all the employees in all the departments.
    Please let me know if there is a way to change the view criteria at run time depending on the values set at run time for one of the view criteria items.
    JDev version am using is '11.1.1.5'
    Thanks,
    Lakshman

    Hi Shay,
    It worked for me without overriding the executeQuery() method in the ViewImpl.java.
    Instead of creating 2 view criteria, I created only one which has both transient variable and the DepartmentId = <bind_DeptId>. With the above code, it worked properly. Now I am using only one view criteria.
    Thank you.

  • How to find table size in run time ?

    Hi all
    I am using JTable problem is. �table data is being changed frequently� I waana method or any idea by which I could find the preferred size of table at run time�
    Thanks & Regards

    but my problem is I have written one renderer for increase the row height at run time behalf of data.. And we are supposed to guess what you are doing from your original question?
    I changed the code in my actionPerformed() method as follows:
    table.setRowHeight(0, table.getRowHeight(0) + 10);
    System.out.println(table.getPreferredSize());
    The preferred size still changes.
    I have no idea what your problem is or why you even care what the table preferred size is. You just add the table to a scroll pane and scroll bars will appear when required.

  • Run time for a Report

    Hi All,
    I have a requirement, where in i want to know whether my report has run for 8 mins or not. If it has run for 8 mins then i have to give an information message saying that the report is taking more than 8 mins so schedule the program in back ground.
    Is this possible ?
    Please let me know how to know during run time the time taken by a report.
    Regards
    Rakesh.

    Hi Dominic,
    The code you mentioned can be put to know what is the time taken by a select statement or the time taken by a particular piece of code. In my program there are several select queries and complex logics.. So i dont think that it is feesible to calculate the run time for each select and then if its increasing 8 mins then to show error !!!!
    My report will be called from an external application. If the program is taking much time it will get timed out. So for a precaution we have to tell them that the way you have given the selection screen filter values its going to take more than 8 mins so better schedule a back ground job.

  • How do I change the start/stop time for multiple songs not just one song at a time?

    How do I chnage the start/stop time for multiple songs not just one song at a time?

    I don't think you can in iTunes.
    Multiple editing in Get Info does not offer an option to change start/stop times.

  • EE says time has run out for my data but I still have 500mb PAYG top-up ?

    Hi. I received 10 gb data when I bought my phone 3 months ago.  EE says the time for this data has run out which is correct- however I still have 500mb of the monthly PAYG topup remaining (this is shown on the data, call, text remaining allowance screen. However away fromWifi I cannot access the internet..  It says I have no data - 'Time Run Out'. Any help appreciated  

    Hi Leanne, I tried contacting Customer Services via phone but just ended up going round in circles with the various options and not being able to speak to a person and basically getting nowhere.  So I went into the local EE shop and a very helpful and patient young lady listened to my story and phoned Customer Services who put her onto the Tech area - then back and forth between the two for over an hour till eventually they reset my account and credited me with a new PAYG monthly pack.  Now I can use the data allowance to access the internet as normal.  The only thing that I believe needs to be checked is that on my next purchase of PAYG I was due to get a 250mb Boost so I need to check I receive this as the text msgs I received from EE stated I was on my first PAYG purchase. Thanks Brendan  

  • Default maximum run time for updates

    Is there a way to change the default "Max run time" for each update? In SCCM 2007 the default run time was 20 minutes per update, now it is 5 minutes. I have machines that repeatedly fail to install updates because the max time of 300 seconds was
    reached.

    Hi,
    What is the powershell command to change the maximum run time?
    Thanks.
    probably this:
    http://technet.microsoft.com/en-us/library/jj850138(v=sc.20).aspx
    Don
    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer", where applicable.
    This helps the community, keeps the forums tidy, and recognises useful contributions. Thanks!)

  • Maximum allowed run time for a task sequence

    I found if i left the maximum allowed run time for a task sequence with a defualt value of "0" in configuration manager 2012 r2 cu2,the required task sequence would never run without a maintenance window larger than
    12H.
    At client side,the servicewindowmanager.log always said this required task sequence had a maximum runtime of 43200 seconds(12h).
    servicewindowmanager.log:
    OnIsServiceWindowAvailable called with: Runtime:43200, Type:5
    Program cannot Run! Setting *canProgramRun to FALSE
    There does not exist a Service Window of this Type, for this duration. The Program will not run.
    If i set maximum allowed run time to 120 minutes,task sequence would run under a 3h mainenance window.
    So if you leave the maximum allowed run time for a task sequence with a value of "0" then client agent will evaluate it as 43200(12h) for a required deployment,is it true? have i missed something?

    Hi,
    That is correct it will default to the same value as a program with a "Unknown" maximum runtime value, Unknown is also evaluated to 0 = 12h so that is correct behaviour.
    Regards,
    Jörgen
    -- My System Center blog ccmexec.com -- Twitter
    @ccmexec

  • Battery run time for Tungsten E?

    What is the total run time for the battery in the Tungsten E assuming the back light is on all the time while playing a song?
    Post relates to: Palm III

    With a brand new T|E in early 2004 I could get about 3 hours of run time in Aeroplayer with screen off.
    I doubt you can get anything like that.
    It would be simpler and less time consuming for everyone if you had started one thread with ALL your T|E battery questions.
    Post relates to: Palm TX

  • Changing sampling time for logging data in DSC

    currently I created lots of shared variables by Modbus server. I'm wondering when I active logging data to Citadel, there is any option for change sampling time for logging data or not. I only saw option for changing base on percentage of value differences.
    Since I want to export them to MS Excel later, I want decrease the number of sample datas by decreasing sampling time.
    Thanks in advance.

    This is my idea that i try
    First, I add Enqueue Message for Enable time case
    Then, I create Enable time cases and write box diagram fallow below pic.
    But when i run program,it don't work, time don't count 
    Please help me.

Maybe you are looking for