ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

JAVA SQL issue with replace_jar

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

  • JAVA SQL issue with replace_jar

    Question please

    I am running the SQLJ REPLACE_JAR command.

    ends with rc=0

    then run SQLJ REFRESH_CLASSES()

    end with rc=0


    now I need to run the replace_jar a second time.

    issue:

    if I logoff my user, and rerun the command - everything works ok with rc = 0

    if I do not logoff and run the command again I get this:

    Message ID . . . . . . : SQL4304 Severity . . . . . . . : 30

    Message type . . . . . : Diagnostic

    Date sent . . . . . . : 17/05/10 Time sent . . . . . . : 17:03:11



    Message . . . . : Java stored procedure or user-defined function

    SQLJ.sqlejReadJ, specific name SQLJ.sqlejReadJ could not load Java class

    com.ibm.db2.jdbc.app.DB2Driver for reason code 3.

    Cause . . . . . : The Java class given by the EXTERNAL NAME clause of a

    CREATE PROCEDURE or CREATE FUNCTION statement could not be loaded. The

    reason codes and their meanings follow:

    1 -- The class was not found on the CLASSPATH.

    2 -- The class did not implement the required interface

    ("com.ibm.db2.app.StoredProc" or "com.ibm.db2.app.UDF") or lacked the Java

    "public" access flag.

    3 -- The default constructor failed or was unavailable.

    Recovery . . . : Ensure that the compiled ".class" file is installed in the

    CLASSPATH, for example under "/QIBM/UserData/OS400/SQLLib/Function". Ensure

    it implements the required Java interfaces and is "public".

    I am not a java expert. I guess that I need to perfrom a command before I can run another replace_jar .
    and it seems that logging off the user, is actually running this command (remember that after re-logon - the replace_jar works fine)


    can someone suggest what I need to run before running the second replace_jar ? (without forcing me to logoff my user)


    many thanks

  • #2
    Re: JAVA SQL issue with replace_jar

    I don't know anything about SQLJ replace_jar but I have had a look for you. This tutorial explains that what you are doing with replace_jar is simply registering the new jar.


    It looks like you have created some kind of stored procedure or something that uses Java. This procedure or whatever it is can be called from SQL. SQL then needs to know where it can find all the relevant jar files. If you update a stored procedure with a new jar file you need to use replace_jar to re-register it to SQL. This value is only used as a reference for setting the classpath. Once a JVM has been loaded for a particular job and the classpath is set, it cannot be changed. A JVM cannot be restarted for a job, instead you must restart the job. If you have been using this Java in your interactive job then that means logging out and back in again.

    Does that make any sense? It is certainly the case for every other Java program I have tried. If you update the jar, you have to restart the job. The only uncertainty surrounds this replace_jar.
    Ben

    Comment


    • #3
      Re: JAVA SQL issue with replace_jar

      Sorry for being late.

      Thanks for your reply.

      I tried many things that will allow me to run the replace_jar more than once, without LOGOFF my user.

      Nothing.

      Is there any sqlj command that "close" the connection to java.


      thanks !!!

      Comment


      • #4
        Re: JAVA SQL issue with replace_jar

        If you "close the connection", in other words end the JVM, then that's your lot for the job. It is only possible to start a JVM once per job. Once it is started the classpath is set and whilst you can add class references to the classpath you cannot change existing references. The only thing you can do is end the job and start again.

        Your problem if I remember is that this is being called from greenscreen interactively which means you can't easily end the job. My recommendation would be to set-up a queue with a bunch of jobs doing the Java processing. If you need to do a hot-replace like this then you could end the jobs and start new ones.
        Ben

        Comment


        • #5
          Re: JAVA SQL issue with replace_jar

          Thanks for your reply. I was out for a while.

          Comment

          Working...
          X