ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Problem with external stored procedure

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

  • #16
    Re: Problem with external stored procedure

    If you were pulling from the cache then you weren't sending a unique sql statement (thus my impression would be that you aren't threadsafe). I could be wrong here, I would try testing in a concurrent user environment. Have two or 3 or more people try it at once and see if they can all get through... I hope I'm wrong and misunderstand something, but I think they'll get all backed up or worse, step on each other's toes and get bad results...
    Your future President
    Bryce

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

    Comment


    • #17
      Re: Problem with external stored procedure

      I don't understand the concept of threadsafe very well.
      I'm trying to read up on it now. I'm calling this routine
      from an action type program that handles a request
      from a browser.
      I'm not overtly starting any threads, although I'm sure
      every program is a thread.
      Any hints as to what I might look for?

      Comment


      • #18
        Re: Problem with external stored procedure

        I'm assuming that you have written a class with methods to do this. Make sure that you don't have any variables outside of your methods that would be considered a global class variable. That's for starters. And chance you could post your JAVA for me to look at?
        Your future President
        Bryce

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

        Comment


        • #19
          Re: Problem with external stored procedure

          Sure, here it is. I'm not sure the best way to send it, so I'll just
          paste it in and re-align it.

          PHP Code:
          public class RTGIRPTS {
            protected 
          DataSource           ds  null;
            protected 
          Connection          con  null;
            protected 
          CallableStatement cs  null;
              
            private 
          String jvErrCd       "";
            private 
          String jvErrMsg     "";

            
          String jvSpace50      "                                                  ";
            
          String jvSpace31      "                               ";
            
          String jvSpace155    jvSpace50+jvSpace50+jvSpace50 "+ "     ";            
            private String jvMessage     = jvSpace50+jvSpace50+jvSpace31;

            private String jvME               = "
          0000000";
            private String jvOwner         = "
          0000000";
            private String jvPgmParms   = jvSpace155;            
            private String jvProgram    = "          ";
            private String jvEMailTo    = jvSpace50;
            String  jvParms             = "";

            public void execute() {
              getDs();
              if  (!(jvErrCd.equals("
          ok"))) {
                return;
              }

              try {  
                con = ds.getConnection();

                String sql = "
          CALL RTGIRPTS (?,?,?)";
                
                cs = con.prepareCall(sql);

                jvParms = jvME+jvOwner+jvMessage+jvPgmParms;

                cs.setString(1,jvProgram);
                cs.setString(2,jvEMailTo);
                cs.setString(3,jvParms);

                cs.registerOutParameter(1,Types.CHAR); 
                cs.registerOutParameter(2,Types.CHAR);
                cs.registerOutParameter(3,Types.CHAR);
                cs.execute();

                jvParms      = cs.getString(3);
                jvMessage    = jvParms.substring(14,145);
              } catch (SQLException sqle) {
                jvErrCd = "
          xx";
                jvErrMsg = sqle.getMessage();
              } catch (Exception e) {
                jvErrCd = "
          xx";
                jvErrMsg = e.getMessage();
              } finally {
                try {
                  if  (cs != null)  cs.close();
                  if  (con != null) con.close();
                } catch (SQLException sqle) {
                  jvErrCd  = "
          xx";
                  jvErrMsg = sqle.getMessage();
                }
              }
            }

            public void getDs() {
              try {  
                if  (ds == null) {
                  ds = (DataSource) javax.rmi.PortableRemoteObject.narrow((new InitialContext()).lookup("
          jdbc/AS400DataSource"),javax.sql.DataSource.class);
                }

                jvErrCd = "
          ok";
              } catch (Exception e) {
                jvErrCd = "
          xx";
              }
            }

            // Setters
            public void setProgram(String Program) {
              jvProgram = (Program+"          ").substring(0,jvProgram.length());
            }

            public void setME(String ME) {
              jvME = ME;
            }
            
            public void setOwner(String Owner) {
              jvOwner = Owner;
            }
            
            public void setPgmParms(String PgmParms) {
              jvPgmParms = (PgmParms+jvSpace155).substring(0,jvPgmParms.length());
            } 

            public void setEMailTo(String EMailTo) {
              jvEMailTo = (EMailTo+jvSpace50).substring(0,jvEMailTo.length());
            }
           

            // Getters
            public String getErrCd() {
              return jvErrCd;
            }
            public String getErrMsg() {
              return jvErrMsg;
            }

            public String getMessage() {
              return jvMessage;
            }

          Comment


          • #20
            Re: Problem with external stored procedure

            could you or an admin wrap that in code tags?
            Your future President
            Bryce

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

            Comment


            • #21
              Re: Problem with external stored procedure

              I don't know what you mean.

              Comment


              • #22
                Re: Problem with external stored procedure

                Thats okay I did it for you

                Look at your previous post....Its beautiful
                All my answers were extracted from the "Big Dummy's Guide to the As400"
                and I take no responsibility for any of them.

                www.code400.com

                Comment


                • #23
                  Re: Problem with external stored procedure

                  Code:
                    protected DataSource           ds  = null;
                    protected Connection          con  = null;
                    protected CallableStatement cs  = null;
                      
                    private String jvErrCd       = "";
                    private String jvErrMsg     = "";
                  
                    String jvSpace50      = "                                                  ";
                    String jvSpace31      = "                               ";
                    String jvSpace155    = jvSpace50+jvSpace50+jvSpace50 "+ "     ";            
                    private String jvMessage     = jvSpace50+jvSpace50+jvSpace31;
                  
                    private String jvME               = "0000000";
                    private String jvOwner         = "0000000";
                    private String jvPgmParms   = jvSpace155;            
                    private String jvProgram    = "          ";
                    private String jvEMailTo    = jvSpace50;
                    String  jvParms             = "";

                  All of these variables need to be inside your methods....not global to the class.
                  Your future President
                  Bryce

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

                  Comment


                  • #24
                    Re: Problem with external stored procedure

                    Thanks,

                    I'll give that a try

                    Comment

                    Working...
                    X