Global Variable in JAVA

Hi I am new to Java but have been programming in other languages for sometime.
What I want to achieve is to have some global variables that I can use in other classes. This was particularly difficult because I want to use these global variable in Switch/Case statements. I thought this was solved by creating the following class
public final class IntObj {
public static final int ftsefut_contract_id = 2;
so in another class i would use IntObj.ftsefut_contract_id in the switch/case and it worked. However, i now am begining to think this is not working. Usng NetBeans, if I change the value of ftsefut_contract_id from 2 to 3 and "clean and rebuild", I am still seeing the value of ftsefut_contract_id to be 2 and not the new value (ie 3) that I have inputed. Can someone please explain is there a better method of having global variables and if not how do I get NetBean or the project to flush itself and reload the new values each time I rebuild.
Thanks

That behaviour is explicitly permitted by the Java specifications.
Use an enum.

Similar Messages

  • Global variables in Java Mapping

    Hi,
    I have a java mapping function in PI 7.1 that transforms an XML document to a legacy data structure which eventually is written to a flat file. The file name is required to be sequenced for each mapping run. For example,
    1. The first message generates FILE_001.dat
    2. the second message generates FILE_002.dat
    3. the counter resets to 001 after 999.
    Due to the complexity of the mapping, I have to use a Java class to map this.
    What is the best way possible to achieve this? I wonder this can be achieved using the GlobalContainer, but I am not sure whether I can access this class from within AbstractTransformation class.
    Any pointers?
    Thanks and best regards,
    Kapila

    Thanks Udo,
    Due to the complexity, I have to use Java Mapping class. The question that I am pondering is around maintaining the sequence as the class is called per execution.
    I have now a not-so-elegant solution, where I retain the sequence value in the file system that gets updated everytime. This way, I can maintain a lock on the file in the unlikely event that the interface is invoked parallely.
    I plan to look at creating a java table on the database to maintain the sequence value using JDBC/JDO. The GlobalContainer is out of the quesion, as far as I see.
    Thanks for your input Udo.
    Best regards,
    Kapila

  • Global Variable as an array

    Hi All,
    Culd you please tell me where I can declare a global variable as an array in PI 7.1.
    In PI 7.O we used to store global variables in java sections and it was recognized across mapping in message mapping
    In PI 7.1 I have declared a variable in init function in functions tab in message mapping but its not recognized in my mapping.
    Could you please help me with this?
    Where I have to declare a global variable so that I can use it anywhere in mapping?
    Thanks in advance
    Best Regards,
    Harleen Kaur Chadha

    Please refer to the below link about how to use global variables in PI 7.1.
    /people/william.li/blog/2008/02/13/sap-pi-71-mapping-enhancements-series-using-graphical-variable
    This link will help you understand how to use graphical valiable as a global variable.
    Thanks,
    Hetal

  • Java Threads vs. Native Global Variables

    A brief description of the problem:
    I am trying to integrate a multi-threaded Java app with legacy Fortran code. The Fortran code in question makes extensive use of global variables in the form of Fortran's Common Block data structure.
    If multiple threads were allowed access to a native routine, they would over write each others data which is stored in global variables.
    If only one thread at a time can have access to the native routine for the duration of the native routine, the whole advantage of using threads is completely nullified.
    These native routines cannot be rewritten (3rd party code) and must be used.
    One solution I envisioned was to load a new copy of the native shared object code for each Java object that used the native code. However, it seems System.loadLibrary() can only be used in a static context.
    Is there any known solution to this problem?

    Here is an elaboration on the earlier suggestions. It's a high overhead solution, because you have to start a bunch of JVMs.
    1. You have a java control program, which will start up a pool of "services", make requests to them, and gather the results.
    2. Each service is a small java program with a native method:
    o java communications front-end.
    o native method declaration.
    o native - in your case fortran - method implementation.
    3. Each service is started using "exec". That puts it in a separate process.
    4, Since each service is a java program, you can use java to do communications between the control program and the service.
    o You could use RMI.
    o You could - perhaps - use java Process communications, i.e., have the services write to stdout, and have the control program capture the output.
    o You could use socket communications.

  • Jdev+ADF Mobile : Error java.lang.NullPointerException,need global variable

    hi, i am using jdeveloper version 11.1.1.1.0.
    i try to get value of field "id" from a table "customer" from input value from "username" and "password" form in welcome / login page.
    the value of field "id" that logged on will be used for further operation like determine relationship with other table for showing data.
    to accomplish that, i create a new java class "bean.java"
    the content is simple, just a few variable like : eeid,eeuser,eepass, and more else.
    each variable have accessors.
    after create "bean.java", i register that class to faces-config.xml in managed beans tab. i give it description like below :
    - name : beanku
    - class : mvc.bean
    - scope : session
    to login, i check the login button with code like this :
    public String cmdSigninee_action() throws ClassNotFoundException, SQLException {      
    String tuser = (String) inputUseree.getValue(); --> value of username
    String tpass = (String) inputPassee.getValue(); --? value of password
    bean ong = (bean) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("beanku"); --> it's ok here
    ong.setSeeid("testing"); --> here is the error
    i got an error message like shown below :
    Target URL -- http://127.0.0.1:7101/madf-mvc-context-root/faces/welcome.jsp
    Dec 4, 2009 11:39:26 PM oracle.jbo.uicli.mom.CpxUtils$Visitor logMainApplicationCpx
    INFO: file:/C:/Documents and Settings/Ong/Application Data/JDeveloper/system11.1.1.1.33.54.07/o.j2ee/drs/madf/madf-mvc-webapp/WEB-INF/classes/mvc/DataBindings.cpx
    Dec 4, 2009 11:39:27 PM oracle.adfinternal.controller.faces.lifecycle.JSFLifecycleImpl setLifecycleContextBuilder
    INFO: ADFc: Initializing ADF Page Lifecycle for the JSF environment, LifecycleContextBuilder is 'oracle.adfinternal.controller.application.model.JSFDataBindingLifecycleContextBuilder'.
    Dec 4, 2009 11:40:21 PM com.sun.faces.application.ActionListenerImpl processAction
    SEVERE: java.lang.NullPointerException
    javax.faces.el.EvaluationException: java.lang.NullPointerException
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:51)
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
         at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
         at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
         at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
         at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.wls.JpsWlsFilter$1.run(JpsWlsFilter.java:96)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.wls.util.JpsWlsUtil.runJaasMode(JpsWlsUtil.java:146)
         at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:140)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:70)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:202)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3588)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2200)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2106)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1428)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: java.lang.NullPointerException
         at mvc.backing.Welcome.cmdSigninee_action(Welcome.java:380)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.el.parser.AstValue.invoke(AstValue.java:157)
         at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:46)
         ... 38 more
    Dec 4, 2009 11:40:21 PM com.sun.faces.lifecycle.InvokeApplicationPhase execute
    WARNING: #{backing_welcome.cmdSigninee_action}: java.lang.NullPointerException
    javax.faces.FacesException: #{backing_welcome.cmdSigninee_action}: java.lang.NullPointerException
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
         at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
         at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
         at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
         at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.wls.JpsWlsFilter$1.run(JpsWlsFilter.java:96)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.wls.util.JpsWlsUtil.runJaasMode(JpsWlsUtil.java:146)
         at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:140)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:70)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:202)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3588)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2200)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2106)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1428)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:51)
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
         ... 37 more
    Caused by: java.lang.NullPointerException
         at mvc.backing.Welcome.cmdSigninee_action(Welcome.java:380)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.el.parser.AstValue.invoke(AstValue.java:157)
         at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:46)
         ... 38 more
    Dec 4, 2009 11:40:21 PM com.sun.faces.lifecycle.Phase doPhase
    SEVERE: JSF1054: (Phase ID: INVOKE_APPLICATION 5, View ID: /welcome.jsp) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@8aa35b]
    <Dec 4, 2009 11:40:21 PM ICT> <Error> <HTTP> <BEA-101017> <[ServletContext@14855001[app:madf module:madf-mvc-context-root path:/madf-mvc-context-root spec-version:2.5], request: weblogic.servlet.internal.ServletRequestImpl@5a2f7[
    POST /madf-mvc-context-root/faces/welcome.jsp?_adf.ctrl-state=4p5g40az1_4 HTTP/1.1
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
    Referer: http://127.0.0.1:7101/madf-mvc-context-root/faces/welcome.jsp;jsessionid=vs4JLZ7ppccm9mdq4z1RJn31c1Qj9ZpLmdHhT2BGTThzP7JnZfmJ!1909271282?_adf.ctrl-state=4p5g40az1_4
    Accept-Language: en-us
    Content-Type: application/x-www-form-urlencoded
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
    Content-Length: 346
    Connection: Keep-Alive
    Cache-Control: no-cache
    Cookie: JSESSIONID=vs4JLZ7ppccm9mdq4z1RJn31c1Qj9ZpLmdHhT2BGTThzP7JnZfmJ!1909271282
    ]] Root cause of ServletException.
    javax.faces.FacesException: #{backing_welcome.cmdSigninee_action}: java.lang.NullPointerException
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
         at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
         at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
         Truncated. see log file for complete stacktrace
    javax.faces.el.EvaluationException: java.lang.NullPointerException
         at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:51)
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
         at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
         Truncated. see log file for complete stacktrace
    java.lang.NullPointerException
         at mvc.backing.Welcome.cmdSigninee_action(Welcome.java:380)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         Truncated. see log file for complete stacktrace
    >
    anyone can help me with those errors? i just need global variable, so i can use it for check relationship with other table.
    or if anyone of you can give me another way to get the value of field "id" from a table?
    thank you so much before! and i am sorry if my english is bad.

    If you select the JSP page in the graphical stuts-config.xml overview in JDeveloper, you should see the properties of the JSP page in the property inspector. One of those properties defines the Java class that handles the action/forwarding/etc.
    Then you should create a new Java-class that extends the original action handling class. Change the property in the graphical stuts-config.xml overview in JDeveloper to this new class.
    Then add an event attribute to the submitbutton element in the form of your JSP page, e.g. seeDetails.
    In your newly created class you can then create a new method: onSeeDetails. This method should be invoked when the submit button is pressed and the form is submitted.
    In the ADF ToyStore demo there are some examples of Java classes that extend the standard action handler. There in the ViewController project.
    ROnald

  • GlobalContainer x Global Variable Java Section

    Guys,
    My requirement: I have a variable that'll be read from message header with DynamicConfiguration and will be used in several UDFs in a message mapping.
    Are there any problems in using either GlobalContainer object or Global Variable in Message Mapping Java Section for storing/recovering this variable?
    And in the case I use Java Sections, suppose I have the following:
    Global Variables
    String param = null;
    Initialization Section
    param = "value";
    Then, what do I need to use in Clean-up Section? Should I give it a null value or an empty string value? I mean, I can't understand the necessity of this section, since garbage collector would handle that variable (and supposing it will be valid only during this message mapping thread).
    Any thoughts?
    Thanks in advance,
    Henrique.

    Hey William,
    thank you for your input.
    Yeah, I thought that too, that clean-up section would be useful when I needed to use .close() methods on the open objects.
    And since java sections are newer, I think they are the prefered way too.
    Regards,
    Henrique.

  • How to go to java section global variable declaration

    Hi all
    i am following this scenario
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417100)ID0446700150DB10376299506581707969End?blog=/pub/wlg/11287
    in this scenario 3rd screen shot is about global variable declaration:
    In order to build the content of the attachment (for this particular requirement) we use a global variable declared and initialized in the global sections :
    can any body tell me how to go to this java section screen , as i am unable to find this java screen....
    Thanks
    sandeep

    even i cant see this edit java section
    i am working on PI 7.1. has this feature been removed in pi 7.1
    this is replaced in PI7.1 ... check this blog on how to use the "global" variable in PI7.1:
    /people/william.li/blog/2008/02/13/sap-pi-71-mapping-enhancements-series-using-graphical-variable
    Regards,
    Abhishek.

  • How to: Transform Activity: Read global/local variable, execute java code

    Could anyone please show me how to do that???

    could you please elaborate your usecase? yes you can read global variable using getVariableData( ) xpath function and pass them as an argument to the processXSLT ( ) xpath function.
    You can read the global or local variables inside java exec using, please refer samples/references/javaexec sample.

  • How do you override global variable values when calling oraxsl or xsl.exe?

    I am a newbie to oracle xslt.
    I have down loaded the latest version of xdk (10.1.0.2...). (Jan 2, 2009).
    In the past I haveI used micorsoft's "msxsl.exe" to perform my transformations.
    I am looking for a more up-to-date transformation tool.
    I found Oracle's version, and thought I would try it out.
    I have run the "bin/xsl.exe -hh" command.
    I read its help data. It states that variables are
    passed by coding a pramater "-V <var> <value>".
    I have also examined the oraxls.bat file.
    I found the documentation on "oracle.xml.parser.v2.oraxsl" class.
    It states that parameters are passed after the "-p" switch.
    It says the value of the -p parameter is "a list of paramemters".
    I don't find this sufficient information to be useful.
    I can spend days guessing, and I might get lucky.
    I thought it my be better to ask for help.
    I need to pass in (override) values for 3 global variables.
    I saw the method
    "setParam(namespace, variable, value)",
    near the documentation for the "oraxsl" class.
    How do you format the options string to communicate more than one param statement?
    (in either xsl.exe and/or oraxsl class).
    Suppose I have an xslt stylesheet as follows:
    ==================================================
    <?xml version="1.0" ?>
    <xsl:stylesheet version="1.1" xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
    <xsl:param name='a' select='"default_a"' />
    <xsl:param name='b' select='"default_b"' />
    <xsl:param name='c' select="'default_c"' />
    <xsl:template match='/'>
    this is value for a: <xsl:value-of select='$a' />
    this is value for b: <xsl:value-of select='$b' />
    this is value for c: <xsl:value-of select=$c' />
    <xsl:apply-templates />
    </xsl:template>
    </xsl:stylesheet>
    ========================================================
    Now as part of the calling of the XSL processor I want to change the value of these
    three global parameters.
    I want:
    a="current_a",
    b="current_b",
    and c="current_c"
    How do I express this using xsl.exe and its paramter string (-V ????).
    and/or how do I express it to the oraxsl class ( -p (xsl, a,"current_a"), (....) )???
    The syntax for specifying this information is not very clear in either situation.
    Of course I am making the "assumption" that by "param" they are
    refering to "global parameters" (as in my stylesheet), rather than some other global parameters of XLST.
    As an aside inquiry:
    I had hopped that the Oracle's xsl Verion 2 routine could handle xslt 2.0 commands
    such as "xsl:for-each-group", since it handled multiple xsl:outputs.
    From reading some of the documentation it seems it only handles xslt 1.0 syntax/commands.
    Is this true? (or is the documentation not up-to-date?).
    Any help on passing param values to xsl.exe and/or "oraxsl" class is appreciated.
    Thanks.

    Here is the line from one of my testing .bat files that passed in one parameter. I can't recall if I've passed in two, but this will give you a starting point for passing in multiple
    java -cp %CPath% oracle.xml.parser.v2.oraxsl -p show_image='yes' %ValXML% %ValXSLT% As for XSLT 2.0 support, it appears it does per {thread:id=503445}

  • How to declare a global variable from a PL/SQL package

    Hi All,
    Using a global variable is a bad practise for all language. However, in my case, I have a PL/SQL package defines all constants, and I want to use them directly via SQL statement, for instance,
    PACKAGE my_const
    IS
         DEFAULT_ZIP_CODE CONSTANT VARCHAR2(5) := '00000';
    END;And I cannot referrence this variable from my select statement as
    SELECT my_const.DEFAULT_ZIP_CODE from dual;I have to create a function via my package, as,
    FUNCTION get_default_zip_code RETURN VARCHAR2
    IS
    BEGIN
         RETURN DEFAULT_ZIP_CODE;
    END;and
    SELECT my_const.get_default_zip_code from dual;I don't want to create functions to referrence the default varaibles. Does anyone have any clues?
    thanks
    Edited by: user4184769 on Jul 19, 2010 8:36 AM

    riedelme wrote:
    thanks for the info. Your scope explanation makes sense even though it is not intuitive to me. I think the usage of package variables should be supported by SQL (they're just values to be copied) Maybe look at it from another language's perspective. You want to use a global PL package variable in Java/C#/Delphi/VB/etc. How would you do it?
    None of these languages can crack open the data segment of a PL code unit, inspect the variables in it, and extract a value from it. Instead, it needs to be done as follows:
    Using sqlplus as the client illustrates how all these languages will need to do it:
    SQL> var value varchar2(20);
    SQL> begin
      2>     :value := SomePackage.someVar;
      3> end;
      4> /So why should SQL behave differently? It is not the same as the PL language. It is not a subset of the PL language. Yeah, PL/SQL blurs the line between these 2 languages making it very simple for us to mix their source code. But PL/SQL is SQL integrated with PL - not PL integrated with SQL. PL has tight hooks into SQL, creating cursors for you, defining bind variables, binding variables and doing the whole Oracle Call Interface bit for you.
    But SQL has no need for PL code, just as it has no need for Java code, or Delphi code or VB code. Yes, it is possible for it to call Java stored procs. As it is possible for it to call PL procs. But these are via the formal call interface of those languages - not via tight integration hooks that blur the languages and make SQL and Java, or SQL and PL, look like a single integrated source code unit.
    Thus SQL has the pretty much the same constraints in calling the PL language as other languages do. What SQL can do is use the PL engine's call interface and tell it "+execute this function and return the result of the function+".

  • Global Variables declaration in PI 7.1

    Hi All,
    In message mapping where can I declare global variables in PI 7.1.
    Thanks and regards
    Uma

    Hi Sarvesh,
    Thank you for the response.
    The blog given by you is on PI 7.0, But icon(Java Sections) is not present in PI 7.1 mapping editor .
    Please guide me how can I proceed further.
    Thanks & regards
    Uma
    Edited by: Uma Balasubramanya on Mar 20, 2009 1:11 PM

  • Reg Global Variable in PI 7.1

    Dear All
    We have a scenario where we need to validate contents of variuos fields in an xml file. As the validations are complex we want to store the exceptions inside a global variable so that all the exceptions can be segregated at a single point.
    Consider the following source structure
    Vendor No.
    Order No.
    Invoice No.
    Claim No.
    Customer No.
    CustomerName
    Needs to be maaped to following target structure
    Vendor No.
    Order No.
    ClientName
    Exception
      Text
    if in the Sender side, Vendor no/orderno/invoice no is not there then the text fied should be populated in the  Reciever side with the exception ,  this challenge has to to be achived using the Global Variable.
    Regrads,
    Sourabh

    Hi Nirmal,
    The exception you are going to send is a Type of Text message or its like java exceptions??
    If you are validating 5 or 6 fields then its better to do it at Message mapping level,use Global variale ,first create a global variable and check the condition if Vendor  not exists pass exception message to Global Variable.
    Then map this global variable to Text message segment in Receiver side.
    I had done validating Two CIDX Orderchange documents using JAVA Mapping,its worked perfectly for my requirement(bit complex requirement).
    Regards,
    Raj

  • Using global variable in package

    Hi. I have created a function (Retrieve_SerialNo) which returns a variable, which I use throughout my package. I would like to assign this variable as a global variable to be used by all functions and procedures in the package. Can someone help me in the declaration of this variable as a global variable? Also, is it necessary for me to initialize this variable whenever the package executes. If yes, how would I do this?
    CREATE OR REPLACE PACKAGE BODY Supply_Item_Interface AS
    FUNCTION Retrieve_SerialNo RETURN VARCHAR2 IS
        v_serial_no VARCHAR2(20);
        CURSOR Serial_Code IS
          SELECT S.Serial_Code
            FROM Spare_Parts s, Orders r
           WHERE s.serial_code = r.serial_code;
      BEGIN
        OPEN Serial_Code;
        LOOP
          FETCH Serial_Code
            INTO v_serial_no;
          EXIT WHEN Serial_Code%NOTFOUND;
          v_serial_no := v_serial_no;
        END LOOP;
        CLOSE Serial_Code;
        RETURN v_serial_no;
      EXCEPTION
        WHEN OTHERS THEN
          RETURN NULL;
      END;

    user13415143 wrote:
    Hi. I have created a function (Retrieve_SerialNo) which returns a variable, which I use throughout my package. I would like to assign this variable as a global variable to be used by all functions and procedures in the package.All variables have scope or "visibility". A variable defined in a procedure is only visible within that procedure.
    A variable defines in a package body. is visible within that package body (i.e. procedures and functions in that package body can "see" that variable.
    A variable defined in the package definition? Well, who can see the definitions of procedures and function in a a package header/definition? Everyone else basically (other PL/SQL packages and procedures and functions). So this is also true for variables defined in the package interface. These are global variables that not only can be used by the code in that package's body, but also can be used by other packages and PL/SQL code.
    So when you create a global variable you need to decide on its scope:
    - define it in package header for global usage in all PL/SQL code
    - define it in package body for global usage within that package only
    CREATE OR REPLACE PACKAGE BODY Supply_Item_Interface AS
    ..snipped..Ugly code as there is no need to use an explicit cursor if returning a value from a single row. Also buggy code. If there are multiple rows returned by the cursor, the function returns the serial of the last random row. How does this make sense?
    This is what I would expect to see from a function like this. You pass it a unique identifier and it returns the applicable attribute (column) value for it.
    E.g.
    create or replace function GetSerialNo( orderNo number ) return number is
      serialNo number;
    begin
      select
        s.serial_code into serialNo
      from spare_parts s,
           orders o  
      where s.serial_code = o.serial_code
      and o.order_no = orderNo;
      return( serialNo );
    exception when NO_DATA_FOUND then
      return( null )
    end;Also note that there is no need to write ugly uppercase code. This is not a proper coding standard. Programming standards for all languages (ranging from C# to Java to Delphi to Visual Basic to C/C++) specify that camelcase should be used for variables and pascalcase for procedures/functions/methods. Uppercase is very seldom used and then only for constant names and compiler options/flags for example.
    Coding reserved words in uppercase? That is just plain silly - and not found in today's programming languages. Do yourself a favour and forget the idiotic standards used by some for PL/SQL and look at the standards for Java and .Net/C# - as the latter are the de facto standards for programming (and have been for the last 2 decades and more).

  • Global Variable in entity beans

    Dear Friends,
    For example let us think that we have an entity bean for Customer.
    and we created an instance of that bean for customer A and then for customer B.
    So will the global variables in Customer bean be shared across Customer A and Customer B or will there be seperate instances for both Customers.
    Thanking You,
    Chamal.

    Your concepts seem to be a little messed up.
    For entity bean, remember the following:
    1. each object/instance of entity bean represents a record in a database
    2. when a client looks up an entity bean (typcially by using findByPrimaryKey method on home object), the record from database is searched and its values are stored in Entity Beans variables (this is probably what you mean by Global Variable. But thats an incorrect terminology in Java/J2EE. Class attribute is the correct word)
    3. In step 2, you fetched a record and that record is represented by a java object, which is nothing but entity bean.
    4. Now if you make changes to this java object, these changes will persist in the database. That is the essence of entity bean.
    5. If you use the home object's findByPrimaryKey method and look for the same record, no new object will be created. The 2 remote objects will point to the same entity bean on the server.
    6. If yo use the home object's findByPrimaryKey method and look for another record/customer, a new object will be created on the server. This new entity bean will map to the new record.
    Note taht the attribtues of CustomerA and customerB will never be shared.
    hope that helps

  • Global variable in servlet & DBPooling questions

    Hello guys,
    I used to develop PHP/ASP, and am new to servlet. I have been searching around for a solution ...
    With Php, we can get the reference of a global variable in any classes->functions...
    How do I do this with servlet ?
    And second..I have developed the DB class as below... I set the datasource to be static, so it initializes only once. Is it a good idea? How would you like to improve this class? any comments?
    package shop.database;
    import javax.sql.DataSource;
    import java.sql.*;
    import org.apache.commons.dbcp.BasicDataSource;
    import org.apache.log4j.Logger;
    import shop.admin.exception.GeneralException;
    public class DdManager {
         static protected Logger logger = Logger.getLogger(DdManager.class);
         private String userName = "root";
    private String password = "";
    private String hostName = "jdbc:mysql://localhost:3306/shop";
    private String database="shop";
         static private DataSource ds;     // set this to be static so all threads share the same job in JVM
         private Statement stmt;
         private Connection conn;
         private ResultSet rs;
         private CallableStatement cs;
    public DdManager() {}
    * setup the data source and return it
         public static DataSource getDataSource(
              String sDrvName,
              String sUserName,
              String sPwd,
              String connectURI) {
              BasicDataSource ds = new BasicDataSource();
              ds.setDriverClassName( sDrvName );
              ds.setUsername( sUserName );
              ds.setPassword( sPwd );
              ds.setUrl( connectURI );
              ds.setMaxActive( 15 );
              ds.setMaxIdle( 10 );
              ds.setMaxWait( 10000 ); // 10 seconds
              return ds;
         * static init of the class
         * this class is will be called only once to initialize the DataSource
         static {
              try {
                   Class.forName( "com.mysql.jdbc.Driver" );
                   ds = getDataSource(     "com.mysql.jdbc.Driver",
                                            "root",
                                            "jdbc:mysql://localhost:3306/shop" );
                   if (ds == null) {
                        String msg = "Connection Pool error";
                        logger.error(msg);
                        throw new GeneralException(msg);
                   logger.info("DataSource has been initialized");
              } catch(Exception exception) {
                   logger.error(exception.toString());
                   try {
                        throw new GeneralException(exception.toString());
                   } catch (GeneralException e) {
                        logger.error(e.toString());
         * get the connection from the pool (DataSource)
    public void openConnection() throws GeneralException {
    try {
         BasicDataSource bds = (BasicDataSource) ds;
         logger.info("NumActive: " + bds.getNumActive() + ", " + "NumIdle: " + bds.getNumIdle());
    conn = ds.getConnection();
    logger.info("Connection of " + database + " has been established");
    } catch(Exception exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    * close the connection will actually return the connection to the pool (Must)
    public void closeConnection() throws GeneralException {
         initResource();
    try {
         if (conn != null){
                   conn.close();
                   logger.info("Connection of " + database + " has been closed");
    } catch(SQLException exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    * prepare the calling stmt
    public void prepareProcedure(String callStatement) throws GeneralException {
         initResource();
    try {
         cs = conn.prepareCall(callStatement);
    } catch(SQLException exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    * set the pass-in parameter for "String"
    public void setParameter(int position, String parameter) throws GeneralException {
    try {
         cs.setString(position, parameter);
    } catch(Exception exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    * set the pass-in parameter for "Integer"
    public void setParameter(int position, int parameter) throws GeneralException {
    try {
         cs.setInt(position, parameter);
    } catch(Exception exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    * execute the procedure and return the resultset
    public ResultSet execProcedure() throws GeneralException {
    try {
         rs = cs.executeQuery();
    } catch(SQLException exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    return rs;
    * close the statment and resultset
         private void initResource() throws GeneralException {
         try {
              if(rs != null) {
                   rs.close();
              if(stmt!= null) {
                   stmt.close();
              logger.info("Statement & Resultset have been free");
         } catch(Exception exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    Thanks mates!
    myy

    Thanks Saish,
    Your response is really appreciated. Sorry about that
    as i didnt know there is 'code' formatting button,
    and I will look into the Singleton pattern.
    As I'm still in the learning stage. Therefore, i
    still have a lot of thing do not understand.
    ... use it in a method signature ...What is "a method signature" ?
    A method signature is basically the method's parameters, return value, name and any access or other modifiers. The following is a method signature:
    static final public void main(final String[] args)Between the braces of the method body is the implementation (or as I already alluded to, the method body).
    Consider using an already-developed connection poolimplementation, such as Jakarta Commons DBCP ...
    I'm trying to implement the Jakarta DBCP. Did I go
    into the wrong way?
    Sorry, did not read the imports. Yes, you are. However, I am confused about what you are trying to implement. You have a static method getDataSource(). You also have a static variable 'ds'. Use one or the other. I would be that there are seemingly random errors cropping up based on whether you remember to call getDataSource() or not.
    You do not, generally, want the data source to be static. Multiple threads might use the class. And if there is only a static data source, you will either need to synchronize the methods that use the data source (resulting in a scaling bottleneck) or not synchronize them (which will totally destroy any concept of a logical unit of work or database transaction).
    .. A static datasource, as in your class, can onlysafely be used by one thread at a time, potentially
    introducing scaling bottlenecks (or race conditions)
    in your system ...
    So, you mean there is no need for the DataSource to
    be static ?
    No, in fact, IMO, it should not be. That is why you are pooling. Use instances. The pool will manage the connections and their availabilty for you.
    Why are you throwing GeneralException everywhere?Here's a question: can someone using your class (a
    caller) realistically be expected to handle a
    database exception?
    When there is a database error, I just want to stop
    the process and redirect the user to an error page. I
    will look into the unchecked exceptions. Thanks.
    Unchecked exceptions do not need to be declared in a method signature or caught within the method body. Checked exceptions do. As such, an added benefit is that unchecked exceptions de-clutter your code.
    In your initResources() method, what happens if theclose() on ResultSet throws an exception
    Oh, yes. I'm so stupid.
    Now I only have ...
         private static DataSource ds;     // set this to
    be static so all threads share the same obj in JVM
         private Connection conn;
         private CallableStatement cs;
    private void initResource() throws GeneralException
    n {
         try {
              if(cs != null) {
                   cs.close();
    logger.info("CallableStatement has been
    as been free");
         } catch(Exception exception) {
         logger.error(exception.toString());
    throw new
    throw new GeneralException(exception.toString());
    You still have issues.
    public void initResources() {
       if (rs != null) {
         try { rs.close(); } catch (SQLException ignore) { ignore.printStackTrace(); }
       if (stmt != null) {
         try { stmt.close(); } catch (SQLException ignore) { ignore.printStackTrace(); }
    }Normally, this type of method would not be called initResources() but rather closeResources() or freeResources(). It would be called from within the 'finally' block of another method using the CallableStatement or ResultSet.
    This is really is problem, would you mind to tell me
    how to handle this(close the connection) if the
    close() on either CallableStatement or Resultset
    throws an exception ?
    See above. Simply log the exception (there is usually nothing meaningful you can do if a close() fails, and it is up to you as a developer if this is an error or just a warning). Another option is to 'chain' exceptions. In your own exception, add a method 'addException(Throwable)'. This would add another exception to a List of exceptions. When you print the stack trace, iterate through the chained exceptions to print them all out. One place where I find this useful is rollback() code. If the original SQL statement fails AND the rollback fails, I definitely want to see that rollback() exception as well in my logs.
    The DB thing makes me headache. What I actually
    wanted is a solution for:
    Let say I have a class "HelloAction.class" contains
    the code:
    public ActionForward XXX() {
         DbManager DB = new DBManager();
         ... do some DB thing here...
         SecondClass SC = new SecondClass();
         SC.doSomeOtherDbThing();
         ... do something else...
         ThirdClass TC = new ThirdClass();
         SC.doMoreOtherDbThing();
    }There are some functions in SecondClass.class and
    ThirdClass.class that will need database connection.
    I consider 'global variable' is because I want these
    two classes are able to use the same
    connection(DbManager) from the function -
    ActionForward XXX().
    What is the best way to implement the above situation
    (sharing the same connection in different classes &
    sub-classes?
    I also just realize that the problem of multi-threads
    with these two class variables..
         private Connection conn;
         private CallableStatement cs;Really headache. I really appreciate any comments.
    Thanks.
    - myyPass the Connection or DataSource to each method or constructor. Call commit() or rollback() from the method that created the transaction.
    - Saish

Maybe you are looking for

  • So I converted NTSC to PAL using nattress, but DVD issue now. Please read

    So with Shanes help last night I managed to make the .mov PAL formatted. Now I went into DVD Studio Pro made my menus made sure it was PAL ready and started the burn process. Yet it failed and the reason that DVD said is " Final PAL (Video):Invalid V

  • For Loop Structure

    Hi... are multiple initializations inside the firt part of a for loop allowed in Java? for (int i = 0, int j = 0; i < someArray.length; ++i, j = j + 2) {     //doin' somethin' }

  • Aperture 3 crash?

    i installed aperture 3 trial, and have been using it for about a day then halfway through editing an image it started to slow and has been ever since. ive restarted my mac twice and managed to delete the image it got stuck on whilst editing but whene

  • Unable to create a simple test client. Error JAXBException

    Resending..... Hi, I am using fusiondrop3 version of JDeveloper, accessed from the fvwm_linux_session_fusion I am getting this error when trying to run a test client. Created a simple AM, VO and EO. I am able to see the data by running the AM Tester.

  • Photo Booth/FaceTime

    How do you change your camera to black and white on the iMac so its black and white on skype calls and facetime calls?