【问题标题】:Calling Oracle Stored Procedure using StoredProcedure provided by Spring Framework使用 Spring Framework 提供的 StoredProcedure 调用 Oracle 存储过程
【发布时间】:2017-06-02 00:43:42
【问题描述】:
我看到一个代码似乎使用 org.springframework.jdbc.object.StoredProcedure 类中的执行方法调用存储过程。地图作为输入传递给此方法。但是,我没有看到存储过程名称或函数名称作为输入传递。 Spring如何保证存储过程中正确的函数被执行?
map.put(FAULT_CODE, faultCode);
map.put(FAULT_MESSAGE, faultMessage);
Map result = this.execute(map);
【问题讨论】:
标签:
java
spring
oracle
stored-procedures
plsql
【解决方案1】:
org.springframework.jdbc.object.StoredProcedure 有 3 个构造函数:
豆类
protected StoredProcedure()
Allow use as a bean.
用于数据源:
protected StoredProcedure(DataSource ds,
String name)
//name - name of the stored procedure in the database
用于创建包装器:
protected StoredProcedure(JdbcTemplate jdbcTemplate,
String name)
//name - name of the stored procedure in the database
在第二种和第三种情况下,您在创建时指定存储过程的名称。我想其中之一是你的情况。