下面是我使用 Java 中的 spring JDBC 模板调用存储过程后得到的异常。
org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{call PKG_IBS_AC_CHANGE_API.P_UPDATE_ACCOUNT_CURRENCY(?, ?, ?, ?, ?, ?, ?, ?, ?)}]; SQL state [null]; error code [17004]; Invalid column type; nested exception is java.sql.SQLException: Invalid column type
at
Caused by: java.sql.SQLException: Invalid column type
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:127)
at org.springframework.jdbc.core.CallableStatementCreatorFactory$CallableStatementCreatorImpl.createCallableStatement(CallableStatementCreatorFactory.java:212)
at org.springframework.jdbc.core.JdbcTemplate.execute(Jdb
所以我使用 spring DEBUG 模式运行了相同的代码,下面是记录器的少量输出。
DEBUG:28-08-2013 17:55:57,503: CallMetaDataProvider - Retrieving metadata for PKG_IBS_AC_CHANGE_API/PPOKEROPS/P_UPDATE_ACCOUNT_CURRENCY
DEBUG:28-08-2013 17:55:58,008: CallMetaDataProvider - Retrieved metadata: IN_ACCOUNT_NAME 1 12 VARCHAR2 true
DEBUG:28-08-2013 17:55:58,011: CallMetaDataProvider - Retrieved metadata: IN_NEW_AC_TYPE 1 12 VARCHAR2 true
DEBUG:28-08-2013 17:55:58,015: CallMetaDataProvider - Retrieved metadata: IN_SHOULD_COMMIT 1 1111 PL/SQL BOOLEAN true
DEBUG:28-08-2013 17:55:58,019: CallMetaDataProvider - Retrieved metadata: OUT_ERROR_INFO 4 1111 PPOKEROPS.TYPE_BONUS_ERROR_INFO true
DEBUG:28-08-2013 17:55:58,022: CallMetaDataProvider - Retrieved metadata: IN_SOURCE 1 12 VARCHAR2 true
DEBUG:28-08-2013 17:55:58,025: CallMetaDataProvider - Retrieved metadata: IN_EVENT_TXN_ID 1 3 NUMBER true
DEBUG:28-08-2013 17:55:58,029: CallMetaDataProvider - Retrieved metadata: IN_SOURCE_TYPE 1 12 VARCHAR2 true
DEBUG:28-08-2013 17:55:58,032: CallMetaDataProvider - Retrieved metadata: OUT_OLD_ACCOUNT_INFO 4 1111 EZECASH.TYPE_USER_ACCOUNT_INFO true
DEBUG:28-08-2013 17:55:58,036: CallMetaDataProvider - Retrieved metadata: OUT_NEW_ACCOUNT_INFO 4 1111 EZECASH.TYPE_USER_ACCOUNT_INFO true
DEBUG:28-08-2013 17:55:58,040: DataSourceUtils - Returning JDBC Connection to DataSource
DEBUG:28-08-2013 17:55:58,045: CallMetaDataContext - Using declared parameter for: IN_ACCOUNT_NAME
..............
DEBUG:28-08-2013 17:55:58,053: SimpleJdbcCall - The following parameters are used for call {call PKG_IBS_AC_CHANGE_API.P_UPDATE_ACCOUNT_CURRENCY(?, ?, ?, ?, ?, ?, ?, ?, ?)} with: {in_source=source, in_source_type=sourcetype, in_event_txn_id=340, in_account_name=name, in_new_ac_type=USD, in_should_commit=0}
DEBUG:28-08-2013 17:55:58,053: SimpleJdbcCall - 1: in_account_name SQL Type 12 Type Name null org.springframework.jdbc.core.SqlParameter
DEBUG:28-08-2013 17:55:58,053: SimpleJdbcCall - 2: in_new_ac_type SQL Type 12 Type Name null org.springframework.jdbc.core.SqlParameter
DEBUG:28-08-2013 17:55:58,053: SimpleJdbcCall - 3: in_should_commit SQL Type 1111 Type Name null org.springframework.jdbc.core.SqlParameter
DEBUG:28-08-2013 17:55:58,054: SimpleJdbcCall - 4: out_error_info SQL Type 1111 Type Name type_bonus_error_info org.springframework.jdbc.core.SqlOutParameter
DEBUG:28-08-2013 17:55:58,054: SimpleJdbcCall - 5: in_source SQL Type 12 Type Name null org.springframework.jdbc.core.SqlParameter
DEBUG:28-08-2013 17:55:58,054: SimpleJdbcCall - 6: in_event_txn_id SQL Type 3 Type Name null org.springframework.jdbc.core.SqlParameter
DEBUG:28-08-2013 17:55:58,054: SimpleJdbcCall - 7: in_source_type SQL Type 12 Type Name null org.springframework.jdbc.core.SqlParameter
DEBUG:28-08-2013 17:55:58,054: SimpleJdbcCall - 8: out_old_account_info SQL Type 1111 Type Name ezecash.TYPE_USER_ACCOUNT_INFO org.springframework.jdbc.core.SqlOutParameter
DEBUG:28-08-2013 17:55:58,054: SimpleJdbcCall - 9: out_new_account_info SQL Type 1111 Type Name ezecash.TYPE_USER_ACCOUNT_INFO org.springframework.jdbc.core.SqlOutParameter
早些时候,元数据和 SimpleJDBC 调用的类型值(如 1111、12、3 等)是不同的。但是我找到了值并使类型相同。设置值仍然存在一些问题。以下是我设置值的方式
parameters.put("in_account_name", "name");
parameters.put("in_new_ac_type", toCurrency);
parameters.put("in_should_commit", new Boolean(true));//I tried 0 and 1
parameters.put("in_source", "source");
parameters.put("in_event_txn_id", new BigDecimal(340.0));//tried 340.00 also
parameters.put("in_source_type", "sourcetype");//these values are varchar
那么谁能帮我找出我到底哪里出错了,为什么我得到无效的列索引异常?