ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Constructing an SQL string in Java

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #46
    Re: Constructing an SQL string in Java

    only 150 MB? Hell by the end of the day I'm using well over 200MB. In version 6.0 I reached 400MB in an 8 hour working day (i think it was an unaddressed memory leak).

    Here is what you can do to try and pinpoint where the bottleneck is. Try timing different pieces of your code. Look into timers in java. There is a lot of stuff out on the web about it. I had done this but I deleted all that code... I know I should have kept it for a time like this...but it got tossed with an older broken version of a project I was working on....

    Ok, I just went out and dug this up for you...

    beginning = System.currentTimeMillis();

    //YOUR CODE TO BE TIMED GOES IN HERE

    ending = System.currentTimeMillis();

    interval = ending - beginning;


    Set up a new bean. Call it something like, timingBean or something. Just make 1 setter and getter method to hold the value of interval. Then after you know interval you can do something like...

    TimingBean myTimer = new TimingBean();

    myTimer.setInteral(interval);

    session.setAttribute("myTimer",myTimer);
    getServletContext().getRequestDispatcher("Timing.j sp").forward(request,response);

    Then Timing.jsp would look like this...

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><&#37;@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    
    <%@page language="java" contentType="text/html; charset=ISO-8859-1"
    	pageEncoding="ISO-8859-1"%>
    <html>
    <head>
    <link rel="stylesheet" href="theme/Master.css" type="text/css">
    <title>Timing</title>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <meta name="GENERATOR"
    	content="IBM Websphere Development Studio Client for iSeries">
    </head>
    <body>
    ${myTimer.getInteravl}
    </body>
    </html>
    You will need to comment out the redirect to your Results.jsp page...

    Just wrap the beginning and ending timer around different parts of the code to figure out what is taking it so long.
    Your future President
    Bryce

    ---------------------------------------------
    http://www.bravobryce.com

    Comment


    • #47
      Re: Constructing an SQL string in Java

      By the way, beginning, ending, and interval will be of type int. And you will want your setter/getter and private types to of int as well in your bean, that way you don't have to do any type conversions
      Your future President
      Bryce

      ---------------------------------------------
      http://www.bravobryce.com

      Comment


      • #48
        Re: Constructing an SQL string in Java

        Sorry it took a while for me to get back. I actually had to do some hardware and windows networking stuff.

        Code:
        So, in the servlet, the section of code would look like this:
        
        beginning = System.currentTimeMillis();
        
        //All of the SQL string building stuff
        
        ending = System.currentTimeMillis();
        
        interval = ending - beginning;
        
        //ResultSet MyQuery stuff
        Then, the bean should look like this:

        Code:
        package scrpsrchPackage;
        
        public class TimingBean 
        {
        	public String interval; //Or, should it be type int?
        
                        public void setInterval(String value)
        	{this.yard = value;}
        	
        	public String getInterval(){return this.type;}
        }
        Then, the jsp page should look just like the one you gave? I just want to make sure that this is all correct before trying it and going through 30 minutes of waiting and trying to shut down WDSC.

        Comment


        • #49
          Re: Constructing an SQL string in Java

          I don't understand why you are having so many problems with WDSC...It sits and runs all day long on my machine. It takes literally 3 seconds to publish my project and pop it up in a browser window... I think you have some configuration issues....

          Anyway...

          try... public int interval;

          and (int value) for the setter

          and public int for the getter.

          make sure you define your variables in the servlet as int.
          Your future President
          Bryce

          ---------------------------------------------
          http://www.bravobryce.com

          Comment


          • #50
            Re: Constructing an SQL string in Java

            Do I declare beginning, ending, and interval to be type int like this?

            int beginning = System.currentTimeMillis();
            int ending = System.currentTimeMillis();
            int interval = ending - beginning;

            If so, it tells me that there is a type mismatch. Apparently, the System.currentTimeMillis(); is of type long.

            Comment


            • #51
              Re: Constructing an SQL string in Java

              my bad. You are right. They are long. Make them long, and make the bean long too. I forgot they were type long.
              Your future President
              Bryce

              ---------------------------------------------
              http://www.bravobryce.com

              Comment


              • #52
                Re: Constructing an SQL string in Java

                Well, I would love to see what is taking so long, but once I enter search criteria into the fields and hit submit, the problem just stops responding. It happens every time, now. The console's last message is the initialization of the servlet. I really think it's the server and not anything to do with the code. What started it all was when I had too many things open at the same time, and WDSC stopped responding with the server running. When rebooting, it gave me an error message like the one that's attached, and it really hasn't acted normal since then.
                Attached Files

                Comment


                • #53
                  Re: Constructing an SQL string in Java

                  *problem=program

                  Comment


                  • #54
                    Re: Constructing an SQL string in Java

                    Here is what I would do....

                    Before you start the test server on your machine, go out to your iSeries and do a WRKACTJOB. See if you can find any jobs with the Current User of whatever the username is that your program uses to make its connections to your DB. The job name will be QZDASOINIT. Then you will need to put a 5 on the line next to it. Then at the next screen put a 10. Check the line that looks something like...
                    Code:
                    User USERNAME from client 127.0.0.1 connected to server.
                    Kill any jobs that originate from your IP address. Then start your server.

                    Do you know if you are using Connection Pooling? If you aren't, you NEED to be.

                    This is just where I would start....it does sound like its a server issue at this point though...
                    Your future President
                    Bryce

                    ---------------------------------------------
                    http://www.bravobryce.com

                    Comment


                    • #55
                      Re: Constructing an SQL string in Java

                      I did the wrkactjob, but couldn't find the job QZDASOINIT. I think we are using connection pooling. I'm not sure, though. I know that once I log onto the iSeries, I do not have to log on again (the connection is kept) until I shut down my PC. I tried to run the application again this morning, and the console messages proceeded past the point that they previously had. Before, it stopped when the servlet was initialized. This time it got to the point where the jsp page was initialized. This leads me to believe even more that it's not a code issue.

                      I looked up some of the error messages that I get like "JVM terminated. Exit code=1073807364," and other people have had the same issue with eclipse. However, I haven't found a good workaround or fix. I opened the data perspective and checked the error log to find out some more information, but I really can't tell what all is going on. It's attached if you want to take a gander. If you have any more ideas, please let me know.

                      Comment


                      • #56
                        Re: Constructing an SQL string in Java

                        It didn't attach...I can't see it...
                        Your future President
                        Bryce

                        ---------------------------------------------
                        http://www.bravobryce.com

                        Comment


                        • #57
                          Re: Constructing an SQL string in Java

                          Sorry, I've run out of room for attachments. How do I clear it out?

                          Comment


                          • #58
                            Re: Constructing an SQL string in Java

                            Go to User CP. Then at the very bottom on left hand side menu you will see Attachments. You can go in there and delete some
                            Your future President
                            Bryce

                            ---------------------------------------------
                            http://www.bravobryce.com

                            Comment


                            • #59
                              Re: Constructing an SQL string in Java

                              Okay, here it is.
                              Attached Files

                              Comment


                              • #60
                                Re: Constructing an SQL string in Java

                                Well, I was reading around on other forums, and one person said that updating to 7.0.0.1 helped them. So, I decided to try to update. When I went into the installation manager and updated, it took the version to 7.0.0.4. All of a sudden, a lot of my path names were screwed up. It would do things like looking for ScrapSearchEAR/ScrapSearchEAR.ear when it really is ScrapSearchEar.ear. It also tried to run index.jsp from ScrapSearch/index.jsp (which is excluding the WebContent folder). So, I just had to create a new project and copy and paste all of the code. Then, I tried to run it, and the exact same thing happened as did before I updated. The program stopped responding and gave me the error message telling me that the java virtual machine was terminated. Any ideas?

                                Comment

                                Working...
                                X