1

我正在使用弹簧 JdbcTemplate。我有这样的查询select top ?* 从表中,我正在设置的值?从这样的调用方法:

jdbcTemplate.query(new PreparedStatementCreator() {
        @Override
        public PreparedStatement createPreparedStatement(final Connection connection) throws SQLException {
            return connection
                    .prepareStatement(**select top ? * from table**);
        }
    }, new PreparedStatementSetter() {
        @Override
        public void setValues(final PreparedStatement ps) throws SQLException {
            ps.setLong(1, 5);
        }
    },
    new ResultSetExtractor<Object>() {
        @Override
        public List<Object> extractData(final ResultSet rs) throws SQLException {
            final List<Object> objects = Lists.newArrayList();
            //assume there is correct code
            return objects;
        }
    });

但这向我抛出了一个 BadSqlGrammerException :@PO 附近的语法不正确。

感谢帮助!

4

0 回答 0