DB2 query runs in IBM Data Studio but not in code

北城余情 提交于 2019-12-12 02:07:03

问题


I am attempting to get the ResultsetMetadata from a spring jdbc query. When I run the code I get a bad SQL grammar error (below). Running the same query in IBM Data Studio returns a result. Part of my confusion is that the error is Parameter index is out of range despite the fact that my query isn't parameterised.

List rsmdList = sourceJdbcTemplate.queryForList("SELECT * FROM MYSCHEMA.MYTABLE fetch first 1 rows only", new ResultSetExtractor() {
            @Override
            public ResultSetMetaData extractData(ResultSet rs) throws SQLException, DataAccessException {
                ResultSetMetaData rsmd = rs.getMetaData();
                return rsmd;
            }
        });

Exception:

org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT * FROM MYSCHEMA.MYTABLE fetch first 1 rows only]; nested exception is com.ibm.db2.jcc.am.vo: [jcc][10145][10844][4.8.87] Invalid parameter 1: Parameter index is out of range. ERRORCODE=-4461, SQLSTATE=42815

来源:https://stackoverflow.com/questions/26582744/db2-query-runs-in-ibm-data-studio-but-not-in-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!