2
我有一个存储过程,只有一个整数输出参数和5个varchar输入参数,无论我尝试了什么,我似乎无法得到输出参数。我已经在db上运行了sproc,它带有数据,所以我看不到我做错了什么。simplejdbccall输出参数
有谁知道如何从simplejdbccall获取输出参数吗?
我有这样的事情:
SimpleJdbcCall simpleJdbcCall =
new SimpleJdbcCall(getDatasourceForEnvironment()).withProcedureName("_Get_Id").declareParameters(
new SqlParameter("MyID", Types.VARCHAR), new SqlParameter("MySourceID", Types.VARCHAR),
new SqlParameter("MyLocationID", Types.VARCHAR), new SqlParameter("MyVisitID", Types.VARCHAR),
new SqlParameter("MyVisitDate", Types.VARCHAR));
HashMap< String, String > input = new HashMap< String, String >();
input.put("MyID", myObj.getMyID());
input.put("MySourceID", myObj.getMySourceID());
input.put("MyLocationID", myObj.getMyLocationID());
input.put("MyVisitID", myObj.getMyVisitID());
input.put("MyVisitDate", myObj.getMyVisitDate());
System.out.println(simpleJdbcCall.execute(input));
当您调用函数(而不是过程)时,Spring默认不会返回OUT参数,并且期望返回值以及OUT参数。最好的方法是始终将'new SqlParameter()'定义为'new SqlInOutParameter()',这样spring就会用返回值更新map中的out参数。但不确定任何性能影响 – SashikaXP