简单计数查询中的 Oracle 无效列
Oracle Invalid Column on simple count query
目前正在尝试使用 jdbctemplate 对 oracle 数据库进行非常简单的 运行 查询,运行 出现以下错误:
PreparedStatementCallback; uncategorized SQLException for SQL; Invalid
column type; nested exception is java.sql.SQLException: Invalid column
type
列
SYSTEM_UNIQUE_ID VARCHAR2(50 CHAR)
SYSTEM_TYPE_ID NUMBER(4,0)
通话
public int getSystemUniqueIDCount(final String systemUniqueID, final String systemTypeID) throws SQLException {
String checkCountQuery = "select count(*) as count from master_account where system_unique_id = ? and system_type_id = ?";
Map<String, Object> row = getTemplate().queryForMap(checkCountQuery , new PreparedStatementSetter() {
@Override
public void setValues(PreparedStatement pstmt) throws SQLException {
pstmt.setString(1, systemUniqueID.toUpperCase());
pstmt.setInt(2, Integer.parseInt(systemTypeID));
}
});
return (int) row.getOrDefault("count", 0);
}
如有任何帮助,我们将不胜感激。
queryForMap() 不将 PreparedStatementSetter() 作为参数,而是在我的例子中假设它是一个 object[]。这意味着它试图将 preparedStatementsetter 本身的值作为查询中的参数插入,这显然会失败。
感谢 Mike Mnemonic 和 Alex Poole。
目前正在尝试使用 jdbctemplate 对 oracle 数据库进行非常简单的 运行 查询,运行 出现以下错误:
PreparedStatementCallback; uncategorized SQLException for SQL; Invalid column type; nested exception is java.sql.SQLException: Invalid column type
列
SYSTEM_UNIQUE_ID VARCHAR2(50 CHAR)
SYSTEM_TYPE_ID NUMBER(4,0)
通话
public int getSystemUniqueIDCount(final String systemUniqueID, final String systemTypeID) throws SQLException {
String checkCountQuery = "select count(*) as count from master_account where system_unique_id = ? and system_type_id = ?";
Map<String, Object> row = getTemplate().queryForMap(checkCountQuery , new PreparedStatementSetter() {
@Override
public void setValues(PreparedStatement pstmt) throws SQLException {
pstmt.setString(1, systemUniqueID.toUpperCase());
pstmt.setInt(2, Integer.parseInt(systemTypeID));
}
});
return (int) row.getOrDefault("count", 0);
}
如有任何帮助,我们将不胜感激。
queryForMap() 不将 PreparedStatementSetter() 作为参数,而是在我的例子中假设它是一个 object[]。这意味着它试图将 preparedStatementsetter 本身的值作为查询中的参数插入,这显然会失败。
感谢 Mike Mnemonic 和 Alex Poole。