无法执行UPDATE是NamedParameterJdbcTemplate

问题描述 投票:1回答:1

我想通过JDBC API和Spring的是NamedParameterJdbcTemplate执行更新到SnappyData行的表。

Error is:

Caused by: java.sql.SQLException: **(SQLState=XCL14 Severity=20000) The column position '1' is out of range.  The number of columns for this ResultSet is '0'.**
    at com.pivotal.gemfirexd.internal.shared.common.error.DefaultExceptionFactory40.getSQLException(DefaultExceptionFactory40.java:121)
    at com.pivotal.gemfirexd.internal.shared.common.error.ExceptionUtil.newSQLException(ExceptionUtil.java:148)
    at com.pivotal.gemfirexd.internal.client.am.SqlException.getSQLException(SqlException.java:419)
    at com.pivotal.gemfirexd.internal.client.am.ColumnMetaData.getColumnType(ColumnMetaData.java:644)
    at com.pivotal.gemfirexd.internal.client.am.PreparedStatement.setString(PreparedStatement.java:1203)
    at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.setString(HikariProxyPreparedStatement.java)
    at org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:429)
    at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:235)
    at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:150)
    at org.springframework.jdbc.core.PreparedStatementCreatorFactory$PreparedStatementCreatorImpl.setValues(PreparedStatementCreatorFactory.java:292)
    at org.springframework.jdbc.core.PreparedStatementCreatorFactory$PreparedStatementCreatorImpl.createPreparedStatement(PreparedStatementCreatorFactory.java:244)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:623)
    ... 70 more
Caused by: ERROR XCL14: The column position '1' is out of range.  The number of columns for this ResultSet is '0'.
    at com.pivotal.gemfirexd.internal.client.am.ColumnMetaData.checkForValidColumnIndex(ColumnMetaData.java:856)
    at com.pivotal.gemfirexd.internal.client.am.ColumnMetaData.getColumnType(ColumnMetaData.java:638)

The NamedParameter SQL looks like this:

UPDATE generic_table_10 SET (VERSION = :version, FK_1 = :fk , COL_1 = :col1, COL_2 = :col2, COL_3 = :col3, COL_4 = :col4, COL_5 = :col5, COL_6 = :col6, COL_7 = :col7, COL_8 = :col8, COL_9 = :col9, COL_10 = :col10) WHERE (ID = :id and VERSION = :oldVersion)

注:版本列类型是整型。列类型的所有其余的都是字符串。

The SQL looks like this, which seems alright to me:

UPDATE generic_table_10 SET (VERSION = ?, FK_1 = ? , COL_1 = ?, COL_2 = ?, COL_3 = ?, COL_4 = ?, COL_5 = ?, COL_6 = ?, COL_7 = ?, COL_8 = ?, COL_9 = ?, COL_10 = ?) WHERE (ID = ? and VERSION = ?)
spring-jdbc snappydata
1个回答
0
投票

我这个解决自己...语法是坏的。我删除了括号和现在的工作。下面是SQL现在:

UPDATE generic_table_10 SET VERSION = ?, FK_1 = ? , COL_1 = ?, COL_2 = ?, COL_3 = ?, COL_4 = ?, COL_5 = ?, COL_6 = ?, COL_7 = ?, COL_8 = ?, COL_9 = ?, COL_10 = ? WHERE ID = ? and VERSION = ?

我必须说,尽管我缺乏的SQL语法技能,该错误信息是有点误导!

© www.soinside.com 2019 - 2024. All rights reserved.