问题描述
我在Oracle 11g上具有一个pl/sql过程,该过程具有以下参数:
I have a pl/sql procedure on an Oracle 11g that has the following parameters:
PROCEDURE validate_product
( product_id_in IN varchar2 ,
username_in in varchar2,
source_in varchar2,
source_id_in varchar2 ,
isEuProduct in boolean ,
error_code out varchar2,
product_type out varchar2
)
我正在尝试使用以下代码在java中调用上述存储过程:
I am trying to call the above stored procedure from within java using the following code:
cstmt = getConnection().prepareCall("begin " + DBUtil.SCHEMANAME + ".PRODUCT_UTILITIES.validate_product(:1,:2,:3,:4,:5,:6,:7); end;");
cstmt.registerOutParameter(6, Types.CHAR);
cstmt.registerOutParameter(7, Types.CHAR);
cstmt.setString(1, productId);
cstmt.setString(2, username);
cstmt.setString(3, sourceName);
cstmt.setString(4, sourceId);
cstmt.setBoolean(5, isEUProduct);
cstmt.execute();
java变量的类型都是String
,除了isEUProduct
是boolean
.每当我运行上述程序时,都会出现以下错误:
The types of the java variables are all String
with the exception of isEUProduct
which is boolean
. Whenever i run the above program i get the following error:
PLS-00306: wrong number or types of arguments in call to validate_product ORA-06550: line 1, column 7: PL/SQL: Statement ignored"
我必须已对该程序进行了一百次调试,但是一切似乎都是正确的类型,并且参数数量也正确.
I must have debugged the program a hundred times but everything seem to be the correct type and the number of arguments are correct.
我完全不知道自己在做什么错.用谷歌搜索我怀疑也许我没有正确设置布尔参数.
I am completely stuck as to what it is i am doing wrong. Having googled around i suspect that maybe i am not setting the boolean parameter correctly.
有什么想法吗?
推荐答案
当我们遇到这个问题时,我感到很惊讶,但是Oracle JDBC驱动程序不支持将布尔值传递到存储过程中.弥补:)
I was amazed when we ran into this, but the Oracle JDBC Driver doesn't support passing booleans into Stored Procedures.... Ya, I'm not making that up :)
这篇关于使用带有布尔IN参数的CallableStatement在Java中调用Oracle PL/SQL过程会产生PLS-00306 oracle错误:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!