使用spring的SimpleJdbcCall执行存储过程而不提供输出

时间:2017-03-28 14:57:15

标签: java spring oracle jdbc jdbctemplate

这是我的DAO类,它有一个连接到数据库的数据源,并重新运行以下内容:

2017-03-28 09:49:42 DEBUG DataSourceUtils:327 - Returning JDBC Connection to DataSource
2017-03-28 09:49:42 DEBUG CallMetaDataContext:380 - Using declared parameter for: PRICETOLERANCE_CSR
2017-03-28 09:49:42 DEBUG SimpleJdbcCall:313 - Compiled stored procedure. Call string is [{call Z_GETPRICETOLERANCEREJECTS(?)}]
2017-03-28 09:49:42 DEBUG SimpleJdbcCall:289 - SqlCall for procedure [Z_GETPRICETOLERANCEREJECTS] compiled
2017-03-28 09:49:42 DEBUG SimpleJdbcCall:395 - The following parameters are used for call {call Z_GETPRICETOLERANCEREJECTS(?)} with {}
2017-03-28 09:49:42 DEBUG SimpleJdbcCall:398 - 1: priceTolerance_csr, SQL type -10, type name null, parameter class [org.springframework.jdbc.core.SqlOutParameter]
2017-03-28 09:49:42 DEBUG JdbcTemplate:1062 - Calling stored procedure [{call Z_GETPRICETOLERANCEREJECTS(?)}]
2017-03-28 09:49:42 DEBUG DataSourceUtils:110 - Fetching JDBC Connection from DataSource
2017-03-28 09:49:43 DEBUG JdbcTemplate:1136 - CallableStatement.execute() returned 'false'
2017-03-28 09:49:43 DEBUG JdbcTemplate:1137 - CallableStatement.getUpdateCount() returned -1
2017-03-28 09:49:43 DEBUG DataSourceUtils:327 - Returning JDBC Connection to DataSource
2017-03-28 09:49:43 INFO  GenerateReportDaoImpl:59 - [null]

GenerateReportDaoImpl

@Component
public class GenerateReportDaoImpl {

    private static Logger logger = Logger.getLogger(GenerateReportDaoImpl.class);
    private DataSource dataSource;
    private JdbcTemplate jdbcTemplate = new JdbcTemplate();
    private SimpleJdbcCall jdbcCall;

    public JdbcTemplate getJdbcTemplate() {
        return jdbcTemplate;
    }

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    public DataSource getDataSource() {
        return dataSource;
    }

    @Autowired
    public void setDataSource(DataSource dataSource) {
        this.jdbcTemplate = new JdbcTemplate(dataSource);
        this.jdbcCall = new SimpleJdbcCall(dataSource);
    }

    public String getReportEmailFromDB(String lookupCode){
        String sql = "select lookup_description from ussco_lookup_table where lookup_code = ?";
        return jdbcTemplate.queryForObject(sql, new Object[]{lookupCode},String.class);
    }

    public ArrayList<Object> getRecordsFromDatabase(String procedureName) {
        logger.log(Level.INFO,procedureName);
            Map<String, Object> out =  jdbcCall.withProcedureName(procedureName)
                .declareParameters(new SqlOutParameter("priceTolerance_csr", OracleTypes.CURSOR, new PriceToleranceFailureRptRowMapper() )).execute();


        logger.log(Level.INFO,out.values());
        return new ArrayList<>();
    }
}

0 个答案:

没有答案