[英]Java stored procedure or user-defined function could not call Java method
After I created a Java external stored procedure in DB2 as in my previous question , the call在我之前的问题中,在 DB2 中创建了一个 Java 外部存储过程之后,调用
call user1.send_mail(
P_TO => 'me@domain.com'
,P_CC => NULL
,P_BCC => NULL
,P_FROM => 'me@domain.com'
,P_SUBJECT => 'db2 java subject'
,P_TEXT_MSG => 'db2 java test'
,P_HTML_MSG => null
,P_ATTACH_NAME => null
,P_ATTACH_MIME => null
,P_ATTACH_BLOB => null
,P_SMTP_HOST => 'domain.com'
,P_SMTP_PORT => 465
,P_USER_NAME => 'me@domain.com'
,P_PASSWORD => 'secret');
fails it due to the following error:由于以下错误而失败:
Java stored procedure or user-defined function "USER1.SEND_MAIL", specific name "SQL201208113215436" could not call Java method "send_mail", signature "(Ljava/lang/String".. SQLCODE=-4306, SQLSTATE=42724, DRIVER=3.68.61
Java 存储过程或用户定义 function “USER1.SEND_MAIL”,具体名称“SQL201208113215436”无法调用 Java 方法“send_mail”,签名“(Ljava/lang/String”.. SQLCODE=-4306, SQLSTATE=42724, DRIVER= 3.68.61
I made sure that all parameters that have no default values receive non- NULL
values.我确保所有没有默认值的参数都收到非
NULL
值。 What else is necessary for this to work?这还需要什么?
Update:更新:
The db2diag.log
file contains the following error message that I formatted for readability: db2diag.log
文件包含以下错误消息,为了便于阅读,我对其进行了格式化:
MESSAGE : java.lang.NoSuchMethodError:
db2/smtp.send_mail(
Ljava/lang/String;
Ljava/lang/String;
Ljava/lang/String;
Ljava/lang/String;
Ljava/lang/String;
Ljava/lang/String;
Ljava/lang/String;
Ljava/lang/String;
Ljava/lang/String;
Ljava/sql/Blob;
Ljava/lang/String;
ILjava/lang/String;
Ljava/lang/String;)V
It is clear that the integer P_SMTP_PORT
parameter of the Java method is missing between the 2nd and 3d last lines.很明显,Java 方法的 integer
P_SMTP_PORT
参数在第 2 行和 3d 最后一行之间丢失。 It looks like it has been totally skipped, even though my SQL call includes this parameter.看起来它已被完全跳过,即使我的 SQL 调用包含此参数。 What does this mean?
这是什么意思? Also, what is the significance of the extra
I
in front of Ljava
on the 2nd last line?另外,最后一行第二行
Ljava
前面的额外I
有什么意义?
The JAR file is being registered from a C# application, using the following code:正在使用以下代码从 C# 应用程序注册 JAR 文件:
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = "sqlj.db2_install_jar";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("blob", DB2Type.Blob).Value = File.ReadAllBytes(args[4]);
cmd.Parameters.Add("jarname", DB2Type.VarChar, 257).Value = "javadb2";
cmd.Parameters.Add("deploy", DB2Type.Integer).Value = 0;
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
cmd.CommandText = "SQLJ.REFRESH_CLASSES";
cmd.ExecuteNonQuery();
}
I checked and made sure that the JAR file correctly trickles down to C:\ProgramData\IBM\DB2\DB2COPY1\function\jar\USER1\JAVADB2.jar
after the code above runs, and that it is still in the correct format.我检查并确保 JAR 文件在上面的代码运行后正确地下降到
C:\ProgramData\IBM\DB2\DB2COPY1\function\jar\USER1\JAVADB2.jar
As per Table 17. SQL Data Types Mapped to Java Declarations on p.根据表17。SQL 数据类型映射到第 Java页的声明。 241 of IBM DB2 10.5 for Linux, UNIX, and Windows Developing User-defined Routines (SQL and External) ,
BLOB
SQL data type maps to java.sql.Blob
Java data type, not to byte[]
that I had initially. 241 of IBM DB2 10.5 for Linux, UNIX, and Windows Developing User-defined Routines (SQL and External) ,
BLOB
SQL data type maps to java.sql.Blob
Java data type, not to byte[]
that I had initially.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.