我正在尝试通过 JDBC API 和 Spring 的 NamedParameterJdbcTemplate 对 SnappyData 行表执行更新。
错误是:
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)
NamedParameter SQL 如下所示:
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)
注意: VERSION 列类型是整数。所有其余的列类型都是字符串。
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 = ?)