Java Code Examples for org.springframework.jdbc.core.SqlReturnResultSet

Following code examples demonstrate how to use org.springframework.jdbc.core.SqlReturnResultSetfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.jdbc.core.SqlReturnResultSetand various code implementation of this class.

    public MuidInboundCheckProgressStoredProcedure(DataSource dataSource, String procedureCall) {
        super(dataSource, procedureCall);
        declareParameter(new SqlParameter("session_id", Types.NUMERIC));

        declareParameter(new SqlReturnResultSet("result", new MuidSessionModelResultSetExtractor()));
        compile();
    } 


    public AllCountryStoredProcedure(JdbcTemplate jdbcTemplate) {
        super(jdbcTemplate, "getAllCountry");
        CountryRowMapper countryRowMapper = new CountryRowMapper();
        declareParameter(new SqlReturnResultSet("AllCountry", countryRowMapper));
        compile();
    } 

    public CategoriesStoredProcedure(DataSource dataSource, String procedureCall) {
        super(dataSource, procedureCall);
        declareParameter(new SqlParameter("in_search_str", Types.VARCHAR));

        declareParameter(new SqlReturnResultSet("result", new CategoriesNameIdRowMapper()));
        compile();
    } 

    public CustomerStoredProcedure(JdbcTemplate jdbcTemplate){
        super(jdbcTemplate, "getCustomer");
        CustomerRowMapper customerRowMapper = new CustomerRowMapper();
        declareParameter(new SqlReturnResultSet("customer", customerRowMapper));
        declareParameter(new SqlParameter("id", Types.VARCHAR));
    } 

    public HsqldbLengthFunction(JdbcTemplate jdbcTemplate) {
        super.setJdbcTemplate(jdbcTemplate);
        super.setSql("FUNCTION_TEST");
        super.declareParameter(new SqlReturnResultSet("result", new ResultSetExtractor<Integer>() {
            @Override
            public Integer extractData(ResultSet rs) throws SQLException, DataAccessException {
                while(rs.next()) {
                    return rs.getInt(1);
                }
                return 0;
            }
        }));
        super.declareParameter(new SqlParameter("str", Types.VARCHAR));
        compile();
    } 

    public OrderHeaderExportProcedure(DataSource ds) {
        super(ds, "dbo.testProcedure");
        declareParameter(new SqlParameter("@name", Types.VARCHAR));
        declareParameter(new SqlReturnResultSet("Result", (rs, row) -> {
            try {
                Order.Row order = new Order.Row(rs.getInt("id"));
                order.setId(rs.getLong("id"));
                order.setName(rs.getString("name"));
                order.setDate(rs.getDate("date"));

                return order;
            }
            catch (Exception e){
                throw new RuntimeException(e);
            }
        }));
    } 

Advertisement
Javadoc
Represents a returned java.sql.ResultSet from a stored procedure call.

A ResultSetExtract

or, RowCallbackHandler or RowMapper must be provided to handle any returned rows.

Returned java.sql.ResultSet ResultSets - like all stored procedure parameters - must have names. @author Thomas Risberg @author Juergen Hoeller

Read More
Advertisement