Skip to content

JdbcTemplate failed to get data from StoredProc by using column alias [SPR-7506] #12163

Closed
@spring-projects-issues

Description

@spring-projects-issues

Liu, Yinwei David opened SPR-7506 and commented

Hi,

Here is a bug in JdbcTemplate which cannot get data from StoredProc by using column alias.

To reproduce the issue:
#1 Create a sybase stored proc:
CREATE PROCEDURE dbo.sp_test_column_alias
AS
BEGIN
select id as test_id, title as test_name from movies
END

#2 Run java code below
String sql = "sp_test_column_alias";
ResultSet rs = ((ResultSetWrappingSqlRowSet) jdbc.queryForRowSet(sql)).getResultSet();
rs.next();
System.out.println(rs.getString("test_name"));

#3 we will get an exception Invalid column name , it should use column label to get data instead of column name according to the method: ResultSet.getString(String columnLabel)

The issue is that Spring JDBCTemplate internal uses com.sun.rowset.CachedRowSetImpl to hold all data from a sp query, however, it fail to use label to get data.

David


Affects: 3.0.4

Referenced from: commits 1247d20, 90636f6

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions