Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/374.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Java源代码调用Postgres过程无效_Java_Postgresql_Weblogic - Fatal编程技术网

从Java源代码调用Postgres过程无效

从Java源代码调用Postgres过程无效,java,postgresql,weblogic,Java,Postgresql,Weblogic,我正在使用Postgres 12,并试图从Java源代码调用一个存储过程。当我试图从类中的一个简单函数调用该过程时,它正在工作并给出输出,但当我试图在运行在WebLogic上的应用程序中调用该过程时,它不起作用 public int test(String i_oid、String i_msisdn、String i_cardtype、String i_content、Double i_clientid、String i_smscid){ int o_rc=-1; 试一试{ stmt=conne

我正在使用Postgres 12,并试图从Java源代码调用一个存储过程。当我试图从类中的一个简单函数调用该过程时,它正在工作并给出输出,但当我试图在运行在WebLogic上的应用程序中调用该过程时,它不起作用

public int test(String i_oid、String i_msisdn、String i_cardtype、String i_content、Double i_clientid、String i_smscid){
int o_rc=-1;
试一试{
stmt=connection.prepareCall(“呼叫打包短信$enqueue\u短信(?,,,,,,,,,,,,,?)”;
registerOutParameter(9,java.sql.Types.DOUBLE);
stmt.setDouble(1,i_clientid);
stmt.setString(2,i_oid);
stmt.setString(3,i_msisdn);
stmt.setString(4“”);
标准设置管柱(5,i_卡式);
stmt.setString(6“”);
stmt.setString(7,i_内容);
stmt.setString(8,i_smscid);
stmt.execute();
o_rc=(int)stmt.getDouble(9);
如果(o_rc==0){
log.log_sys(Level.INFO,“SMS到MSISDN:[“+i_MSISDN+”]已测试,cliendId:[“+i_clientid.toString()+”);
}否则{
log.log_sys(Level.INFO,“无法测试SMS:RC:[“+o_RC+”]MSISDN:[“+i_MSISDN+”],cliendId:[“+i_clientid.toString()+”]”;
}
}捕获(SQLRecoverableException sqlre){
log.log_sys(Level.ERROR,“#DB_执行:调用test1()SQLRecoverableException”+sqlre);
log.log_sys(Level.WARN,“#DB_执行:DB Connection Closed=[“+disconnectDB()+”]);
}捕获(SQLE){
log.log_sys(Level.ERROR,“#DB_执行:调用test()异常”+e);
log.log_sys(Level.WARN,“#DB_执行:DB Connection Closed=[“+disconnectDB()+”]);
}最后{
试一试{
如果(stmt!=null)stmt.close();
}捕获(异常e2){
log.log_sys(Level.ERROR,“#DB_执行:语句关闭异常”+e2);
}
}
返回o_rc;
}
存储过程:

CREATE OR REPLACE PROCEDURE pkg_sms$enqueue_sm(
    i_clientid double precision,
    i_oid text,
    i_ms text,
    i_serv_type text,
    i_card_type text,
    i_sub_type text,
    i_content text,
    i_smsc_id text,
    INOUT o_rc double precision DEFAULT NULL::double precision)
LANGUAGE 'plpgsql'
AS $BODY$
BEGIN
    INSERT INTO cnp.tbl_sm_queue (seqnum, clientid, oid, ms, serv_type, card_type, sub_type, content, status, smsc_id, create_on)
    VALUES (nextval('seq'), i_clientid, i_smsc_id, i_ms, i_serv_type, i_card_type, i_sub_type, i_content, 'I', i_smsc_id, current_timestamp);
    o_rc := 0;
   
    EXCEPTION
        WHEN others THEN
        get stacked diagnostics
        o_rc   = returned_sqlstate;
            o_rc := - 1 * ABS(o_rc);
           
END;
$BODY$;
我得到的错误是:

org.postgresql.util.psqleexception:此语句未声明OUT参数。使用{?=call…}声明一个


该错误建议在调用带有OUT参数的存储过程时使用以下语法:

stmt = connection.prepareCall("{?= call pkg_sms$enqueue_sm(?,?,?,?,?,?,?,?,?)}");

该错误建议在调用带有OUT参数的存储过程时使用以下语法:

stmt = connection.prepareCall("{?= call pkg_sms$enqueue_sm(?,?,?,?,?,?,?,?,?)}");

这也不起作用。org.postgresql.util.psqleException:错误:pkg_sms$enqueue_sm(双精度、字符变化、字符变化、字符变化、字符变化、字符变化)是一个过程提示:要调用过程,请使用call。位置:15只有本机调用适用于以下过程:call proc()您能提供存储过程的代码吗?此错误表示存储过程只有8个参数。我已更新了上面存储过程的代码。它显示了8个参数,因为我给出了out参数的默认值,这也不起作用。org.postgresql.util.psqleException:错误:pkg_sms$enqueue_sm(双精度、字符变化、字符变化、字符变化、字符变化、字符变化)是一个过程提示:要调用过程,请使用call。位置:15只有本机调用适用于以下过程:call proc()您能提供存储过程的代码吗?此错误表示存储过程只有8个参数。我已更新了上面存储过程的代码。它显示了8个参数,因为我给出了out参数的默认值