使用springboot(JPA或JDBCTemplate)连接到oracle函数的问题

时间:2019-05-17 14:12:01

标签: oracle function spring-boot jdbctemplate simplejdbccall

I am trying to call an oracle function using spring boot.
String X = "some string length more than 200 characters";
String Y = "some string length more than 200 characters";

MyFunc(X,Y,null,null,null,"NONE")
All the fields are VARCHAR2 and also return VARCHAR2.
As all fields are string, we don't have entity class for this.

我尝试使用: 1. SimpleJdbcCall 2. Spring数据JPA

SimpleJdbcCall jdbcCall = new SimpleJdbcCall(jdbcTemplate)
          .withCatalogName("XYZ") //package name
          .withFunctionName("BATCH_MYFUNCTION")
    .useInParameterNames("ASTR","BSTR","CSTR","DSTR","ESTR","FSTR");
  SqlParameterSource in = new MapSqlParameterSource().addValue("ASTR", param1,OracleTypes.VARCHAR)
          .addValue("BSTR", param2,OracleTypes.VARCHAR)
          .addValue("CSTR", param3,OracleTypes.VARCHAR)
          .addValue("DSTR", param4,OracleTypes.VARCHAR)
          .addValue("ESTR", param5,OracleTypes.VARCHAR)
          .addValue("FSTR", param6,OracleTypes.VARCHAR)
          ;
  //First parameter is function output parameter type and here the func is returning a string value.
  return jdbcCall.executeFunction(String.class, in);

该函数应从数据库返回字符串响应。 错误:函数中缺少输入和输出参数

0 个答案:

没有答案