Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/329.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.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
在Spring JAVA中从oracle PLSQL函数获取结果集时出错_Java_Spring_Plsql_Spring Data_Stored Functions - Fatal编程技术网

在Spring JAVA中从oracle PLSQL函数获取结果集时出错

在Spring JAVA中从oracle PLSQL函数获取结果集时出错,java,spring,plsql,spring-data,stored-functions,Java,Spring,Plsql,Spring Data,Stored Functions,我不熟悉spring boot开发和java 我在这里尝试在SimpleJDBCall.executeFunction方法的帮助下从spring boot调用Oracle PLSQL函数。我的plsql函数返回单个表行。在java中,我试图将函数的结果/输出存储在Map数据类型中,但每当我试图运行应用程序时,就会出现如下所述的错误 PLSQL函数: CREATE TABLE test.account1 ( account_id INT, name VARCHAR2(20) );

我不熟悉spring boot开发和java

我在这里尝试在SimpleJDBCall.executeFunction方法的帮助下从spring boot调用Oracle PLSQL函数。我的plsql函数返回单个表行。在java中,我试图将函数的结果/输出存储在Map数据类型中,但每当我试图运行应用程序时,就会出现如下所述的错误

PLSQL函数:

CREATE TABLE test.account1 (
 account_id INT,
 name       VARCHAR2(20)
);

INSERT INTO test.account1 VALUES ( 1, 'Bob' );
INSERT INTO test.account1 VALUES ( 2, 'Nob' );

create or replace function test.get_accounts
(Acc_id in Account1.account_id%Type)
return account1%rowtype
as
l_cust_record account1%rowtype;
begin
select * into l_cust_record from account1
where account_id=Acc_id;
return(l_cust_record);
end;
/
Java方法:

@SuppressWarnings("unchecked")
public void testFunctionTablerow(){
    this.jdbcTemplate =new JdbcTemplate(datasource);
    System.out.println("1");
    simpleJdbcCall = new SimpleJdbcCall(jdbcTemplate).withFunctionName("get_accounts");
    System.out.println("2");
    SqlParameterSource in= new MapSqlParameterSource().addValue("Acc_id", 1);
    System.out.println("3");
    //Map<String, Object> out = simpleJdbcCall.executeFunction(Map.class, in);
    Map<String, Object> out= simpleJdbcCall.executeFunction(Map.class, in);
    System.out.println(out);

}
当函数返回整行时,您能帮助我并让我知道用java存储plsql函数ouput值的正确方法是什么吗。如果您知道任何其他方法来调用此类返回复杂输出的函数,请与我们分享

谢谢

您可以尝试调用returningResultSet方法,如下所述:


您的错误是两行信息日志,与任何错误无关。感谢Andrei的及时回复,我将尝试此方法并在此处更新状态。您好Andrei,returningResultSet方法不适用于我。我试过了,但是我遇到了同样的问题。如果你遇到了错误,你能发布错误吗?在上面的示例中,没有错误输出Yes,Andrei。我只得到了我在错误:我的问题中提到的那几行。当我怀疑你没有调用执行函数的代码时,我没有得到任何输出。我创建了相同的示例,在登录函数调用中得到了PL SQL错误。在代码中什么调用testFunctionTablerow方法?
2018-07-12 12:18:34.620  INFO 1560 --- [nio-8000-exec-2] o.s.b.f.xml.XmlBeanDefinitionReader      : Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
2018-07-12 12:18:34.669  INFO 1560 --- [nio-8000-exec-2] o.s.jdbc.support.SQLErrorCodesFactory    : SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase, Hana]