下面是我使用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
早期的类型值如1111,12,3等对于元数据和SimpleJDBC调用是不同的。但我发现了价值并使类型相同。设置值仍然存在一些问题。 以下是我设置值的方法
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
所以任何人都可以帮我找出我出错的地方以及为什么我会收到无效的列索引异常?