简体   繁体   English

在DB2中调用Java存储过程时出现错误-4304

[英]Error -4304 when calling a Java stored procedure in DB2

Here's a sample Java class that I wrote 这是我编写的示例Java类

public class Sleeper  {

    public static void Sleep(int seconds){

        try {
            Thread.sleep(seconds * 1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } 
    }
}

and I wish to call this as a stored procedure this way : 我希望通过这种方式将其称为存储过程:

DROP PROCEDURE DEM.SLEEPUTIL@

-- echo "ETAPE 2 DE 3 > Suppression puis instllation du JAR";
CALL SQLJ.REMOVE_JAR('DEM.SLEEPER_JAR')@
CALL SQLJ.REFRESH_CLASSES()@
CALL SQLJ.INSTALL_JAR("file:///Sleeper.jar",'DEM.SLEEPER_JAR',0)@
CALL SQLJ.REFRESH_CLASSES()@

-- echo "ETAPE 2 DE 3 > CREATION DE LA PROCEDURE ";
CREATE PROCEDURE DEM.SLEEPUTIL (IN NUM INTEGER) 
  COMMIT ON RETURN NO 
  SPECIFIC SLEEPUTIL 
  DYNAMIC RESULT SETS 0 
  DETERMINISTIC 
  LANGUAGE JAVA 
  PARAMETER STYLE JAVA 
  NO DBINFO 
  FENCED 
  THREADSAFE 
  NO SQL 
  PROGRAM TYPE SUB
  EXTERNAL NAME 'DEM.SLEEPER_JAR:com.desj.visa.db.procedures.Sleeper!Sleep'

And I'm repeatedly getting this error: 我一再得到这个错误:

14:54:00  [CALL - 0 row(s), 0.032 secs]  [Error Code: -4304, SQL State: 42724]  DB2 SQL Error: SQLCODE=-4304, SQLSTATE=42724, SQLERRMC=DEM.SLEEPUTIL;SLEEPUTIL;/db2/db2d095/sqllib/function/jar/DEM/SLEEPER_J, DRIVER=4.3.85
CALL DEM.SLEEPUTIL(3);
... 1 statement(s) executed, 0 row(s) affected, exec/fetch time: 0.032/0.000 sec [0 successful, 0 warnings, 1 errors]

What is wrong with this? 这有什么问题?

I found It. 我找到了。

The problem was related to the Java version installed on the server. 该问题与服务器上安装的Java版本有关。

The server has Java 1.5 and the code I deployed to was compiled in 1.6. 服务器有Java 1.5,我部署的代码是在1.6中编译的。

So I recompiled everything to 1.5 and deployed it. 所以我将所有内容重新编译为1.5并进行部署。

Everything works fine now so you guys have a good example on how to deploy a Java stored procedure on DB2. 现在一切正常,所以你们就如何在DB2上部署Java存储过程有一个很好的例子。

Cheers. 干杯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM