Re: help with calling methods

TL;DR--OK, here are 2 things for you to check
1 - are you making changes to your object in a scope as a passed by value variable?
public void myMethod(MyObject o){
  o.my_int = 66;
}when you return from this method, my_int will be the same as it was before you entered.
2 - are you making changes to what you think is your object, but is a local copy?
class MyClass{
  String s = "This is a test";
  MyClass{
   String s = "My inialized String";
}even through you changed s in your constructor (you can say any method here), you defined a local variable called s and actually modified the local variable leaving your class variable s altered.

alright guys all yall who posted replies thanks.
i found out what was wrong. my program was working perfectly. I had flaws in basic math equations that made me get 0 for all those things.

Similar Messages

  • Need help with calling method

    I'm new to Java, trying to pass a required class so I can graduate this semester, and I need help figuring out what is wrong with the code below. My assignment is to create a program to convert celsius to fahrenheit and vice versa using Scanner for input. The program must contain 3 methods - main, convert F to C, method, and convert C to F method. Requirements of the conversion methods are one parameter which is an int representing temp, return an int representing calculated temp after doing appropriate calculation, should not display info to user, and should not take in info from user.
    The main method is required to ask the user to input a 1 for converting F to C, 2 for C to F, and 3 to end the program. It must include a while loop that loops until the user enters a 3, ask the user to enter a temp, call the appropriate method to do the conversion, and display the results. I'm having trouble calling the conversion methods and keep getting the following 2 compiler errors:
    cannot find symbol
    symbol : method farenheitToCelsius(int)
    location: class WondaPavoneTempConverter
    int celsius = farenheitToCelsius(intTemp);
    ^
    cannot find symbol
    symbol : method celsiusToFarenheit(int)
    location: class WondaPavoneTempConverter
    int farenheit = celsiusToFarenheit(intTemp);
    The code is as follows:
    public static void main(String[] args) {
    // Create a scanner
    Scanner scanner = new Scanner(System.in);
    // Prompt the user to enter a temperature
    System.out.println("Enter the temperature you wish to convert as a whole number: ");
    int intTemp = scanner.nextInt();
    System.out.println("You entered " + intTemp + " degrees.");
    // Prompt the user to enter "1" to convert to Celsius, "2" to convert to
    // Farenheit, or "3" to exit the program
    System.out.println("Enter 1 to convert to Celsius, 2 to convert to Farenheit, or 3 to exit.");
    int intConvert = scanner.nextInt();
    // Convert temperature to Celsius or Farenheit
    int celsius = farenheitToCelsius(intTemp);
    int farenheit = celsiusToFarenheit(intTemp);
    while (intConvert >= 0) {
    // Convert to Celsius
    if (intConvert == 1) {
    System.out.println("Celsius is " + celsius + " degrees.");
    // Convert to Farenheit
    else if (intConvert == 2) {
    System.out.println("Farenheit is " + farenheit + " degrees.");
    // Exit program
    else if (intConvert == 3) {
    break;
    else {
    System.out.println("The number you entered is invalid. Please enter 1, 2, or 3.");
    //Method to convert Celsius to Farenheit
    public static int celsiusToFahrenheit(int cTemp) {
    return (9 / 5) * (cTemp + 32);
    //Method to convert Farenheit to Celsius
    public static int fahrenheitToCelsius(int fTemp) {
    return (5 / 9) * (fTemp - 32);
    I readily admit I'm a complete dunce when it comes to programming - digital media is my area of expertise. Can anyone point me in the right direction? This assignment is due very soon. Thanks.

    1) consider using a boolean variable in the while statement and converting it to true if the input is good.
    while (inputNotValid)
    }2) put the code to get the input within the while loop. Try your code right now and enter the number 30 when your menu requests for input and you'll see the infinite loop.... and why you need to request input within the loop.
    3) Fix your equations. You are gonig to have to do some double calcs, even if you convert it back to int for the method return. Otherwise the results are just plain wrong. As a good test, put in the numbers -40, 0, 32, 100, and 212. Are the results as expected? (-40 is the only temp that is the same for both cent and fahr). I recommend doing double calcs and then casting the result to int in the return. for example:
    int a = (int) (20 + 42.0 / 3);  // the 42.0 forces the compiler to do double calc.4) One of your equations may still be plain wrong even with this fix. Again, run the test numbers and see.
    5) Also, when posting your code, please use code tags so that your code will be well-formatted and readable. To do this, either use the "code" button at the top of the forum Message editor or place the tag [code] at the top of your block of code and the tag [/code] at the bottom, like so:
    [code]
      // your code block goes here.
    [/code]

  • Help with calling methods of different classes

    I have two classes. In class A I read a line of input from the console
    myVar= x.readLine();
    then I call a method of the same class (A)
    methodA(); i get NULLPOINTEREXCEPTION here
    in this method I wish to call another method but this time of class B so I create an instance of class B in class A
    private B instanceVar;
    and then proceed to create the method call to class B
    instanceVar.methodB(myVar); i get NULLPOINTEREXCEPTION here
    What am I doing wrong?

    What am I doing wrong?Not posting a short snippet of java code that demonstrates your problem.
    In class A I read a line of input from the console
    myVar= x.readLine();
    How is that related to the NPE's?
    then I call a method of the same class (A)
    methodA(); i get NULLPOINTEREXCEPTION hereSomething is probably wrong in methodA(). Impossible to say anything more with the information given.
    private B instanceVar;
    and then proceed to create the method call to class B
    instanceVar.methodB(myVar); i get NULLPOINTEREXCEPTION hereDid you ever assign instanceVar to an actual object with something like instanceVar = new B(); ?

  • Need help with Sound Methods

    Hi, I am new to java and need help with sound methods.
    q: create a new method that will halve the volume of the positive values and double the volume of the negative values.
    Message was edited by:
    Apaula30

    duplicate message #2

  • Help In Call Method Using types Tables.

    dear gurus
    im having a problem in my code please help me
    TYPES: BEGIN OF itab,
              vtext TYPE tvfkt-vtext,
              fkart TYPE vbrk-fkart,
              fkdat TYPE vbrk-fkdat,
              vbeln TYPE vbrk-vbeln,
              END OF itab.
    DATA:  itab1 TYPE itab OCCURS 0 WITH HEADER LINE.
      DATA:  itab2 TYPE itab OCCURS 0 WITH HEADER LINE.
    SELECT *
        INTO CORRESPONDING FIELDS OF TABLE itab1
        FROM vbrk
        INNER JOIN vbrp ON vbrp~vbeln = vbrk~vbeln
        WHERE vbrk~fkart IN fkart
        AND   vbrk~fkdat IN fkdat
        AND   vbrp~vstel IN vstel
        AND   vbrk~kunag IN kunag
        AND   vbrp~matnr IN matnr.
    LOOP AT itab1.
        SELECT SINGLE vtext FROM tvfkt
          INTO itab1-vtext WHERE fkart EQ itab1-fkart
          AND spras EQ 'EN'.
        IF itab1-fkart EQ 'F2'.
          CONCATENATE 'Tax' itab1-vtext INTO itab1-vtext SEPARATED BY space.
        ENDIF.
        SELECT SINGLE bstkd FROM vbkd INTO itab1-bstkd
          WHERE vbeln EQ itab1-aubel.
        SELECT SINGLE name1 FROM kna1 INTO itab1-name1 WHERE
          kunnr EQ itab1-kunag.
        MODIFY itab1.
        COLLECT itab1 INTO itab2.
        MOVE-CORRESPONDING itab1 TO itab2.
        CLEAR itab1.
      ENDLOOP.
    LOOP AT itab2.
        SELECT SINGLE kbetr FROM konv INTO itab2-kbetr
        WHERE kschl EQ 'PR00'
        AND   knumv EQ itab2-knumv.
        itab2-kwert = itab2-fklmg * itab2-kbetr.
        itab2-gst   = itab2-kwert * 21 / 100.
        itab2-sed   = itab2-kwert * 1 / 100.
        itab2-gt    = itab2-kwert + itab2-gst + itab2-sed.
        MODIFY itab2.
      ENDLOOP.
    CALL METHOD w_handle->insert_full
            EXPORTING
              n_vrt_keys        = 1
              n_hrz_keys        = 1
              n_att_cols        = 3
              sema              = t_sema[]
              hkey              = t_hkey[]
              vkey              = t_vkey[]
              online_text       = t_online[]
              data              = itab2   " "ITAB2" is not type-compatible with formal parameter "DATA". <- ERROR
            EXCEPTIONS
              dim_mismatch_data = 1
              dim_mismatch_sema = 2
              dim_mismatch_vkey = 3
              error_in_hkey     = 4
              error_in_sema     = 5
              inv_data_range    = 6
              error_in_vkey     = 7.

    Hi,
    In your case, please change itab2 into itab2[].
    Because you defined itab2 with header line, itab2 means header line in the method call.
    Cheers,

  • Help with calling a Get URL

    I am having a problem with calling a series of web pages
    within my movie. I have an index.fla that I publish to html. Within
    the index.html, I am calling multiple swf files to load content.
    Home.swf loads when the index page displays. Then the user clicks
    on any button and each button loads another swf replacing the main
    content with perhaps loading it's own swf files of content also.
    Everything is working fine. However, on one called swf file, called
    students.swf, I also have a menu swf file that is called when
    students loads. This menu swf file has text listed with
    actionscripting calling a data file that causes the text to expand
    and rollout and display a label of the url. When the user clicks on
    the list name I have a get url to the url of the label. Everything
    works fine in the swf files when I test the movies for the swf for
    the menu file and for the student file swf. However, when I publish
    and run the index page and start testing out the student swf that
    is called, the menu will not open up a new browser window with the
    link designated in the get url. I can't figure it out! It works
    fine in the swf files, but not when I test it out through the index
    controlling file. Please Help!!!

    if you're using as2, try adding
    this._lockroot=true;
    to the movieclip that contains getURL, the student file
    swf.

  • I need help with this method, i don't know how to call it correct.

    public void method397(byte byte0, int i)
            if(byte0 != 6)
                for(int j = 1; j > 0; j++);
            aByteArray1405[anInt1406++] = (byte)(i + cacheMod.method246());
        }This code is for a Game client im making for a 2dmmorpg, the method was refactored by a friend but he isn't online at the moment because his on holiday; This method sends a packet to the server, i have handled it in the server;
    So i would think you would call it like this;
    super.engineStream.method397((byte)6, 103);But that gives me a huge exception, so please could someone explain how i could fix?
    Thanks
    Ill get the error in a second.

    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at Gui.ClientStreamLoader(Gui.java:328)
            at Gui.actionPerformed(Gui.java:323)
            at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
            at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
            at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
            at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
            at javax.swing.AbstractButton.doClick(Unknown Source)
            at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
            at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknow
    Source)
            at java.awt.Component.processMouseEvent(Unknown Source)
            at javax.swing.JComponent.processMouseEvent(Unknown Source)
            at java.awt.Component.processEvent(Unknown Source)
            at java.awt.Container.processEvent(Unknown Source)
            at java.awt.Component.dispatchEventImpl(Unknown Source)
            at java.awt.Container.dispatchEventImpl(Unknown Source)
            at java.awt.Component.dispatchEvent(Unknown Source)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
            at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
            at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
            at java.awt.Container.dispatchEventImpl(Unknown Source)
            at java.awt.Component.dispatchEvent(Unknown Source)
            at java.awt.EventQueue.dispatchEvent(Unknown Source)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
            at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
            at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
            at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
            at java.awt.EventDispatchThread.run(Unknown Source)

  • Need help with Calling objects

    I have created an object named "user" and I currently have 1 Frame in my program. The first frame is called "LogonFrame" and the second is called "UserDataFrame".
    In the main method of the application I declare a "User" object as user and then call LogonFrame to retreive the logon_name and password from the user. The logon_name and password will be placed in the User object to be accessed throughout the application.
    When I compile the application I receive the following error message:
    Error: (85) variable user not found in class GL2.LogonFrame
    *I know that 85 is the line number that the error is located
    *GL2 is the name of the package.
    Has anyone ever encountered this error before, and if so how can I fix this error.
    *Listed below is the code used in the User object if it helps at all.
    Jason Franz
    // Copyright (c) 2003 Jason T. Franz
    package GL2;
    * A Class class.
    * <P>
    * @author Jason T. Franz
    public class User extends Object {
    private static int user_id;
    private static String first_name;
    private static String last_name;
    public static void User(){
    user_id = 0;
    first_name = "";
    last_name = "";
    //sets the user ID
    public static void setUserID(int newID){
    user_id = newID;
    //Returns the User ID
    public static int getUserID(){
    return user_id;
    //Sets the User First Name
    public static void setFirstName(String newFirstName){
    first_name = newFirstName;
    //Gets the Users First Name
    public static String getFirstName(){
    return first_name;
    //Sets the Users Last Name
    public static void setLastName(String newLastName){
    last_name = newLastName;
    public static String getLastName(){
    return last_name;
    //Resets all data in the User Class
    public static void reset(){
    user_id = 0;
    first_name = "";
    last_name = "";

    The code below is a small portion of the program.
    If it helps at all I am useing Oracle JDeveloper version 3.2.3 with JDK1.2.2_JDeveloper
    This section is the User object
    // Copyright (c) 2003 Jason T. Franz
    package GL2;
    * A Class class.
    * <P>
    * @author Jason T. Franz
    public class User extends Object {
      private String first_name;
      private String last_name;
      public User(){
        first_name = "Jason";
        last_name = "Franz";
      //Sets the User First Name
      public void setFirstName(String newFirstName){
        first_name = newFirstName;
      //Gets the Users First Name
      public String getFirstName(){
        return first_name;
      //Sets the Users Last Name
      public void setLastName(String newLastName){
        last_name = newLastName;
      public String getLastName(){
        return last_name;
      //Resets all data in the User Class
      public void reset(){
        first_name = "";
        last_name = "";
        logon_name = "";
        user_password = "";
    }Here is the main method.
    // Copyright (c) 2003 Jason T. Franz
    package GL2;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    * GL2.DevilsHead
    * <P>
    * @author Jason T. Franz
    public class DevilsHead {
      public User user = new User();
       * Constructor
      public DevilsHead() {
        AddUserFrame frame = new AddUserFrame();
        //Center the window
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = frame.getSize();
        if (frameSize.height > screenSize.height) {
          frameSize.height = screenSize.height;
        if (frameSize.width > screenSize.width) {
          frameSize.width = screenSize.width;
        frame.setLocation((screenSize.width - frameSize.width)/2, (screenSize.height - frameSize.height)/2);
        frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });
        frame.setVisible(true);
       * main
       * @param args
      public static void main(String[] args) {
        try  {
          UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        catch (Exception e) {
          e.printStackTrace();
        new DevilsHead();
    }and here is the Frame which calls the user object to display the Information.
    // Copyright (c) 2003 Jason T. Franz
    package GL2;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    * A Swing-based top level window class.
    * <P>
    * @author Jason T. Franz
    public class AddUserFrame extends JFrame {
      BorderLayout borderLayout1 = new BorderLayout();
      JPanel jPanel1 = new JPanel();
      Button button1 = new Button();
       * Constructs a new instance.
      public AddUserFrame() {
        super();
        try  {
          jbInit();
        catch (Exception e) {
          e.printStackTrace();
       * Initializes the state of this instance.
      private void jbInit() throws Exception {
        this.getContentPane().setLayout(borderLayout1);
        this.setSize(new Dimension(400, 300));
        button1.setLabel("button1");
        button1.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            button1_actionPerformed(e);
        this.setTitle("Add a User");
        this.getContentPane().add(jPanel1, BorderLayout.CENTER);
        jPanel1.add(button1, null);
      void button1_actionPerformed(ActionEvent e) {
        System.out.println(user.getFirstName());
        System.out.println(user.getLastName());
    }The error I receive is
    Error: (51) variable user not found in class GL2.AddUserFrame

  • Help with itemStateChanged method

    I have created an applet which diplays a combobox,three buton being play, stop and loop. The program runs but only plays the first two sound files and not the rest. I thin it has something to do with my itemStateChanged() method.
    Any help id be very grateful......
    Heres the programme
    // Java Core Packages
    import java.applet.Applet;
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    //Java extension packages
    import javax.swing.*;
    * Loads and Plays audio clips with
    * the addition of a loop function
    * @author L_Tambiah
    * @version 01
    public class LoadAudioAndPlay extends JApplet
    private AudioClip sound1, sound2, sound3, sound4, sound5, sound6, currentSound;
    private JButton playSound, loopSound, stopSound;
    private JComboBox chooseSound;
    //load the image when the applet begins executing
    public void init()
    Container container = getContentPane();
    container.setLayout( new FlowLayout() );
    String choices[] = { "Bottle", "Flute", "Space music", "Trippy",
    "dandb", "garage"};
    chooseSound = new JComboBox( choices );
    chooseSound.addItemListener(
    new ItemListener()
    //stop sound and change to sound to users selection
    public void itemStateChanged( ItemEvent e )
    currentSound.stop();
    currentSound = chooseSound.getSelectedIndex() == 0 ?
    sound1 : sound5;
    }// end anonymous inner class
    );// end addItemListener method call
    container.add( chooseSound );
    //set up button event handler and buttons
    ButtonHandler handler = new ButtonHandler();
    playSound = new JButton( "Play" );
    playSound.addActionListener( handler );
    container.add( playSound );
    loopSound = new JButton( "Loop" );
    loopSound.addActionListener( handler );
    container.add( loopSound );
    stopSound = new JButton( "Stop" );
    stopSound.addActionListener( handler );
    container.add( stopSound );
    //load sounds and set currentSound
    sound1 = getAudioClip( getDocumentBase(), "bottle.wav" );
    sound2 = getAudioClip( getDocumentBase(), "flute.aif" );
    sound3 = getAudioClip( getDocumentBase(), "spacemusic.au" );
    sound4 = getAudioClip( getDocumentBase(), "trippy.mid" );
    sound5 = getAudioClip( getDocumentBase(), "dandb.wav" );
    sound6 = getAudioClip( getDocumentBase(), "garage.wav" );
    currentSound = sound1;
    } //end method init
    //stop the sound when the user switches web pages
    public void stop()
    currentSound.stop();
    //private inner class to handle button events
    private class ButtonHandler implements ActionListener {
    //process play, loop and stop button events
    public void actionPerformed( ActionEvent actionEvent )
    if ( actionEvent.getSource() == playSound )
    currentSound.play();
    else if ( actionEvent.getSource() == loopSound )
    currentSound.loop();
    else if ( actionEvent.getSource() == stopSound )
    currentSound.stop();
    L.Tambiah
    E0261830

      AudioClip[] clips = {
        sound1, sound2, sound3, sound4, sound5, sound6
      public void itemStateChanged(ItemEvent e) {
        if(e.getStateChange() == ItemEvent.SELECTED) {
          currentSound.stop();
          currentSound = clips[chooseSound.getSelectedIndex()];
      } For more information:
    http://java.sun.com/docs/books/tutorial/uiswing/events/itemlistener.html

  • Need help with drawLine method

    Hello,
    I've been having trouble with a recent programming assignment and the prof isn't being very helpful. I need to call the drawLine method to plot a line between (0,0) and two coordinates entered by the user; is there a way to do this without a JPanel? Here are the specs:
    I've already done Part 1., just posting it to give a complete representation of the assignment.
    Part 1. Implement a ComplexNumber class to represent complex numbers (z = a + bi).
    1) Instance variables:
    private int real; /* real part */
    private int imag; /* imaginary part */
    2) Constructor:
    public ComplexNumber ( int realVal, int imagVal )
    { /* initialize real to realVal and imag to imagVal */ }
    3) Get/Set functions:
    public int getReal ( )
    { /* returns the real part */ }
    public int getImag ( )
    { /* returns the imaginary part */ }
    public void setReal ( int realVal )
    { /* sets real to realVal */ }
    public void setImag ( int imagVal )
    { /* sets imag to imagVal */ }
    Part 2. Implement a ComplexNumberPlot class (with a main method) that gets complex
    numbers from the user and plots them. The user will be prompted a complex number until
    he/she enters 0. The numbers will be input from the keyboard (System.in) and displayed
    in the plot as they are entered. Assume that the user will enter the numbers in blank
    separated format. For example, if the user wants to enter three complex numbers: 3 + 4i,
    5 + 12i, and 15 + 17i, the input sequence will be:
    3 4
    5 12
    15 17
    0 0
    To plot a complex number, you need to draw a line between (0,0) and (real, imag) using
    the drawLine method.
    Name your classes as ComplexNumber and ComplexNumberPlot.
    For simplicity, you can assume that the complex numbers input by the user fall
    into the first quadrant of the complex plane, i.e. both real and imaginary values
    are positive.
    Thanks for any help!

    Ok I've made some progress, here is what I've got.
    public class ComplexNumber
    private int real;
    private int imag;
    public ComplexNumber (int realVal, int imagVal)
    real = realVal;
    imag = imagVal;
    public int getReal()
    return real;
    public int getImag()
    return imag;
    public void setReal(int realVal)
    real = realVal;
    public void setImag(int imagVal)
    imag = imagVal;
    import java.util.Scanner;
    import java.awt.*;
    import javax.swing.*;
    public class ComplexNumberPlot
    public static void main (String [] args)
    ComplexNumber num = new ComplexNumber (1,0);
    Scanner scan = new Scanner (System.in);
    System.out.println("Enter a complex number(s):");
    num.setReal(scan.nextInt());
    num.setImag(scan.nextInt());
    while (num.getReal() + num.getImag() != 0)
    num.setReal(scan.nextInt());
    num.setImag(scan.nextInt());
    System.out.println();
    JFrame frame = new JFrame ("ComplexNumberPlot");
    frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
    ComplexPanel panel = new ComplexPanel();
    frame.getContentPane().add(panel);
    frame.pack();
    frame.setVisible(true);
    class ComplexPanel extends JPanel
    public ComplexPanel()
    setPreferredSize (new Dimension(150,150));
    public void PaintComponent (Graphics page)
    super.paintComponent(page);
    page.drawLine(0,0,100,100);
    However
    1) The JPanel pops up but no line is drawn.
    2) I am not sure how to get the variables I'm scanning for to work in the drawLine method
    Thanks for all your help so far.

  • Need Urgent Help with static methods!!!!

    If I have a static method to which a variable is being passed...for example
    static String doSomething(String str)
    //..doSomething with str and return
    If the method is invoked a second time by a separate entity when it is already in use by one entity(!!!not entity beans) .... will this lead to the second invocation overwriting str while the method is already in use and thus corrupting the variable that the method was passed from the first entity?

    It's also a common misunderstanding about parameters. The method does not receive a variable as its parameter, it receives a reference to an object. And inside the method, the parameter acts just the same as a local variable would. So if two threads call the method (static or not), each thread has its own copy of the parameter.

  • Help with findByDateRange method in CMP enity bean

    Hello,
    I am trying to deploy my entity beans to WebLogic 7, runnning on a Sun Solaris
    box. The application connects to an Oracle 9i database. I am having problems with
    2 queries in my ejb-jar.xml file which correspond to 2 finder methods. These finder
    methods take two java.util.Date parameters. I have read that EJB QL does not support
    dates or date literals in its WHERE clause and one has to use long values of these
    dates. I tried various combinations but haven't been able get the query to work.
    Here is an excerpt from my ejb-jar.xml file
    <query>
    <query-method>
    <method-name>findBySalesOrderID</method-name>
    <method-params>
    <method-param>java.lang.Long</method-param>
    </method-params>
    </query-method>
    <ejb-ql>
    SELECT OBJECT(c) FROM Equipment c
    WHERE c.salesOrderID = ?1
    </ejb-ql>
    </query>
    <query>
    <query-method>
    <method-name>findEquipmentByStagingDateRange</method-name>
    <method-params>
    <method-param>java.util.Date</method-param>
    <method-param>java.util.Date</method-param>
    </method-params>
    </query-method>
    <ejb-ql>
    <![CDATA[
    SELECT OBJECT(c) FROM Equipment c
    WHERE c.equipReqStageDate >= ?1 AND c.equipReqStageDate <= ?2
    ]]>
    </ejb-ql>
    </query>
    <query>
    <query-method>
    <method-params>
    <method-param>java.util.Date</method-param>
    <method-param>java.util.Date</method-param>
    </method-params>
    </query-method>
    <ejb-ql>
    <![CDATA[
    SELECT OBJECT(c) FROM Equipment c
    WHERE c.equipReqShipDate >= ?1 AND c.equipReqShipDate <= ?2
    ]]>
    </ejb-ql>
    </query>
    Do I have to change the method parameters to java.lana.Long or to 'long' literal
    from java.util.Date?
    Here is the finder method signature in the home interface
    public java.util.Collection findEquipmentByStagingDateRange(java.util.Date begDate,
    java.util.Date engDate) throws javax.ejb.FinderException, java.rmi.RemoteException;
    public java.util.Collection findEquipmentByShippingDateRange(java.util.Date begDate,
    java.util.Date engDate) throws javax.ejb.FinderException, java.rmi.RemoteException;
    Do I have to pass in Dates or java.lang.Longs or 'long' literals?
    Any help is really appreciated. Thanks.
    [question.txt]

    Did you try java.sql.Date?
    /k
    "John Carson" <[email protected]> wrote in message
    news:[email protected]...
    >
    Hello,
    I am trying to deploy my entity beans to WebLogic 7, runnning on a SunSolaris
    box. The application connects to an Oracle 9i database. I am havingproblems with
    2 queries in my ejb-jar.xml file which correspond to 2 finder methods.These finder
    methods take two java.util.Date parameters. I have read that EJB QL doesnot support
    dates or date literals in its WHERE clause and one has to use long valuesof these
    dates. I tried various combinations but haven't been able get the query towork.
    Here is an excerpt from my ejb-jar.xml file
    <query>
    <query-method>
    <method-name>findBySalesOrderID</method-name>
    <method-params>
    <method-param>java.lang.Long</method-param>
    </method-params>
    </query-method>
    <ejb-ql>
    SELECT OBJECT(c) FROM Equipment c
    WHERE c.salesOrderID = ?1
    </ejb-ql>
    </query>
    <query>
    <query-method>
    <method-name>findEquipmentByStagingDateRange</method-name>
    <method-params>
    <method-param>java.util.Date</method-param>
    <method-param>java.util.Date</method-param>
    </method-params>
    </query-method>
    <ejb-ql>
    <![CDATA[
    SELECT OBJECT(c) FROM Equipment c
    WHERE c.equipReqStageDate >= ?1 AND c.equipReqStageDate <= ?2
    ]]>
    </ejb-ql>
    </query>
    <query>
    <query-method>
    <method-params>
    <method-param>java.util.Date</method-param>
    <method-param>java.util.Date</method-param>
    </method-params>
    </query-method>
    <ejb-ql>
    <![CDATA[
    SELECT OBJECT(c) FROM Equipment c
    WHERE c.equipReqShipDate >= ?1 AND c.equipReqShipDate <= ?2
    ]]>
    </ejb-ql>
    </query>
    Do I have to change the method parameters to java.lana.Long or to 'long'literal
    from java.util.Date?
    Here is the finder method signature in the home interface
    public java.util.Collection findEquipmentByStagingDateRange(java.util.DatebegDate,
    java.util.Date engDate) throws javax.ejb.FinderException,java.rmi.RemoteException;
    >
    public java.util.CollectionfindEquipmentByShippingDateRange(java.util.Date begDate,
    java.util.Date engDate) throws javax.ejb.FinderException,java.rmi.RemoteException;
    >
    Do I have to pass in Dates or java.lang.Longs or 'long' literals?
    Any help is really appreciated. Thanks.

  • Help with call to BAPI

    Hi all!
    I need help trying to create order with multiple line items in SAP using BAPI.
    I'm very new to SAP and I'm trying to work on a prof of concept to create orders in SAP using/calling BAPI's from Visual Basic (in Visual Studio 2005). I got the .net connector that I'm using for the proxy connection and I'm able to create order with one line item. But the problem is when I try to create one with multiple line items. I'm calling BAPI_SALESORDER_CREATEFROMDAT2 and loading item table with 3 items and also loading the schedule table but what I get is order gets created with 3 line items but all are the same item and its the last one.
    I'm guessing that problem is one how I'm adding the items to the table, it know that I have 3 items but the detail informations gets over written by the last item that I'm adding.
    Any ideas?
    Thank You

    Hi,
      Welcome To SDN!!
    Try this out...
    Report ZBapi .
    data: po_items type table of bapiekpo with header line.
    parameters: p_ebeln type ekko-ebeln.
    call function 'BAPI_PO_GETDETAIL'
    exporting
    purchaseorder = p_ebeln
    ITEMS = 'X'
    ACCOUNT_ASSIGNMENT = ' '
    SCHEDULES = ' '
    HISTORY = ' '
    ITEM_TEXTS = ' '
    HEADER_TEXTS = ' '
    SERVICES = ' '
    CONFIRMATIONS = ' '
    SERVICE_TEXTS = ' '
    EXTENSIONS = ' '
    IMPORTING
    PO_HEADER =
    PO_ADDRESS =
    tables
    PO_HEADER_TEXTS =
    po_items = po_items
    PO_ITEM_ACCOUNT_ASSIGNMENT =
    PO_ITEM_SCHEDULES =
    PO_ITEM_CONFIRMATIONS =
    PO_ITEM_TEXTS =
    PO_ITEM_HISTORY =
    PO_ITEM_HISTORY_TOTALS =
    PO_ITEM_LIMITS =
    PO_ITEM_CONTRACT_LIMITS =
    PO_ITEM_SERVICES =
    PO_ITEM_SRV_ACCASS_VALUES =
    RETURN =
    PO_SERVICES_TEXTS =
    EXTENSIONOUT =
    check sy-subrc = 0.
    loop at po_items.
    write:/ po_items.
    endloop.
    Refer
    http://abap.wikiprog.com/wiki/BAPI_PO_GETDETAIL1
    Regards
    Kiran SURE

  • Please help with this method, cant get it to work correctly.

    any suggestions AT ALL please, im really stuck with this.
    im creating a little animation of pacman, just an animation of it moving buy its self. im using the java elements package so this is all being shown in a drawing window.
    ive made it move fine and go round the window abit eating dots but the code is a mess, and i know i could change some of the main part into a few simple methods and have tried but it seems to stop moving when i try
    import element.*;
    import java.awt.Color;
    static DrawingWindow d = new DrawingWindow(500,500);  
       public static void wait1second()
        //  pause for one tenth of a second second
            long now = System.currentTimeMillis();
            long then = now + 100; // 100 milliseconds
            while (System.currentTimeMillis() < then)
        public static void waitNSeconds(int number)
            int i;
            for (i = 0; i < number; i++) //allows you to determine how long to pause for
                wait1second();
    public static void main(String[] args) {
        //  declaring the variables
        int pacsize1 = 50, pacsize2 = 50;
        int pac1x = 20, pac1y = 20;
        int pacmouth1 = 45, pacangle1 = 270;
        int pacmouth2 = 25, pacangle2 = 320;
        int pacmouth3 = 6, pacangle3 = 348;
        int startmv = 0, stopmv = 33;
        d.setForeground(Color.black);
        Rect bkrnd = new Rect(0,0,500,500);     
        d.fill(bkrnd);
       // while loop used to make the pacman shape move right across the screen with its mouth in three different states
    Arc pacarc = new Arc();
         while (startmv++<stopmv)
            pac1x += 4;
            d.setForeground(Color.yellow);
            pacarc = new Arc(pac1x,pac1y,pacsize1,pacsize2,pacmouth1,pacangle1);
            d.fill(pacarc);
            d.setForeground(Color.black);
            waitNSeconds(1);
            d.fill(pacarc);
            pac1x += 4;
            d.setForeground(Color.yellow);
            pacarc = new Arc(pac1x,pac1y,pacsize1,pacsize2,pacmouth2,pacangle2);
            d.fill(pacarc);
            d.setForeground(Color.black);
            waitNSeconds(1);
            d.fill(pacarc);
            pac1x += 4;
            d.setForeground(Color.yellow);
            pacarc = new Arc(pac1x,pac1y,pacsize1,pacsize2,pacmouth3,pacangle3);
            d.fill(pacarc);
            d.setForeground(Color.black);
            waitNSeconds(1);
            d.fill(pacarc);
    }so i tried making a method to make all the stuf in the while loop alot simpler but it just keeps making the pacman not move at all and im not sure why. heres the code i tried for the method:
    public static void pacmve(int pactestx, int pactesty, int pacsizetest1, int pacsizetest2, int pacmouthtest, int pacangletest)
            pactestx += 4;
            Arc pacarc = new Arc();
            d.setForeground(Color.yellow);
            pacarc = new Arc(pactestx,pactesty,pacsizetest1,pacsizetest2,pacmouthtest,pacangletest);
            d.fill(pacarc);
            d.setForeground(Color.black);
            waitNSeconds(1);
            d.fill(pacarc);
            }it had no problems with the code, but it just doesnt seem to do anything when i call it in the while loop. heres how i used it to try and just make it move across with the mouth in one state:
    while (startmv++<stopmv)
    pacmve(20,20,50,50,45,270);
    }any ideas?
    Edited by: jeffsimmo85 on Nov 22, 2007 2:36 AM

    the clock is still ticking while you do this:
    while (System.currentTimeMillis() < then)
    is that method your design? why not just call Thread.sleep()?
    %

  • Help  For Calling Method........!

    I am confused about a problem. When I access the method of EJB A: such as UpdJob(),it works seccessfully,
    also it is successful when access EJB B: insert(...).
    But when I call the both methods at the same time in a method:
    public void bothmethod(){
    B.insert();..........(the method of EJB B)
    A.UpdJob();........(the method of EJB A)
    the result is that the B.insert() is success and the B.UpdJob failed with exception: No Resource Available,ejbStore failed,getConnection...
    It looks failed to connect the database.
    I don't know what's the matter,who can tell me?
    Thanks in advance.

    you may have closed some resources in calling the B.insert(), and then not establish that resource before calling A.UpdJob()

Maybe you are looking for

  • Creating a business partner using data from a remote legacy system

    Hi Experts, I am trying to make an interface for creating a business partner in SAP CRM from customer data created in a remote legacy system. I want to map the fields in XI. But to create a customer I need a RFC or a BAPI or maybe an IDoc, that inclu

  • Need best practice when accessing an ucm content after being transferred.

    Hi All, I have a business requirement where I need to auto-transfer the content to another UCM when this content expires in the source UCM. This content needs to be deleted after it spends a certain duration in the target UCM. Can anybody advise me t

  • Using SYSDATE in Pre-Defined View Criteria ADF BC

    I'm trying to setup a View Criteria to find records between two dates. So I create a View Criteria and Select my date field from the table and then choose the "Between" operator and then my operand is a Bind Variable. Then in my Bind variables I have

  • Question on "Writing a Java Card applet" by Ed Ort

    Hi, in the wallet apple i defined the variable short balance that is the wallet in the Sim, but i don't understand where the value of this variable is initialized the first time. Could someone help me? Thank you Luigi

  • Can't open files directly from file server (MAVERICKS)

    since updating to Mavericks earlier today i have had the below problem I use a file server at work to access all my work files. i have no problem accessing the servers but when i try and when I double click to open a file (excel, word, pdf, etc) it s