SpringJDBC:SimpleJDCall不';在使用同义词执行存储过程时,无法读取参数的元数据
我试图使用SimpleJDBCall.excute(in)方法执行一个存储过程,但如果使用过程的同义词,它不会读取元数据 这是代码SpringJDBC:SimpleJDCall不';在使用同义词执行存储过程时,无法读取参数的元数据,spring,oracle,jdbc,Spring,Oracle,Jdbc,我试图使用SimpleJDBCall.excute(in)方法执行一个存储过程,但如果使用过程的同义词,它不会读取元数据 这是代码 SimpleJdbcCall optOutCall = new SimpleJdbcCall(dataSource) .withSchemaName("USER_SCH") .withCatalogName("USER") .withProcedureName(ADD_ADDRESS) .declar
SimpleJdbcCall optOutCall = new SimpleJdbcCall(dataSource)
.withSchemaName("USER_SCH")
.withCatalogName("USER")
.withProcedureName(ADD_ADDRESS)
.declareParameters(
new SqlOutParameter("returnCode", Types.NUMERIC),
new SqlParameter("product_id", Types.NUMERIC),
new SqlParameter("user_id", Types.NUMERIC),
new SqlParameter("email_address", Types.VARCHAR));
long returnCode = 0;
inputs.addValue("returnCode", returnCode);
inputs.addValue("product_id", 1);
inputs.addValue("user_id", 45673);
inputs.addValue("email_address", "a.b@abc.com");
optOutCall.execute(inputs);
此处“添加地址”“过程存在于名为“用户数据”的模式中的“用户”包下。我在另一个名为“USER\u SCH”的模式中为相同的包/过程创建了一个同义词。当我使用SimpleJDBCall.execute()方法执行代码时,它不会读取metatadata并抛出以下执行选项
Caused by: java.sql.SQLException: ORA-06550: line 1, column 7:PLS-00306: wrong number or types of arguments in call to 'ADD_ADDRESS'ORA-06550: line 1, column 7:PL/SQL: Statement ignored
下面是日志消息
[07 Oct 2014 10:32:49,019] [DEBUG] [org.springframework.jdbc.core.simple.SimpleJdbcCall]: [JdbcCall call not compiled before execution - invoking compile]
[07 Oct 2014 10:32:49,019] [DEBUG] [org.springframework.jdbc.datasource.DataSourceUtils]: [Fetching JDBC Connection from DataSource]
[07 Oct 2014 10:32:49,020] [DEBUG] [org.springframework.jdbc.core.metadata.CallMetaDataProviderFactory]: [Using org.springframework.jdbc.core.metadata.OracleCallMetaDataProvider]
[07 Oct 2014 10:32:49,020] [DEBUG] [org.springframework.jdbc.core.metadata.CallMetaDataProvider]: [Retrieving metadata for USER/USER_SCH/ADD_ADDRESS]
[07 Oct 2014 10:32:49,028] [DEBUG] [org.springframework.jdbc.datasource.DataSourceUtils]: [Returning JDBC Connection to DataSource]
[07 Oct 2014 10:32:49,028] [DEBUG] [org.springframework.jdbc.core.simple.SimpleJdbcCall]: [Compiled stored procedure. Call string is [{call USER.ADD_ADDRESS()}]]
[07 Oct 2014 10:32:49,028] [DEBUG] [org.springframework.jdbc.core.simple.SimpleJdbcCall]: [SqlCall for procedure [ADD_ADDRESS] compiled]
[07 Oct 2014 10:32:49,028] [DEBUG] [org.springframework.jdbc.core.metadata.CallMetaDataContext]: [Matching [returnCode, product_id, user_id,email_address] with []]
[07 Oct 2014 10:32:49,028] [DEBUG] [org.springframework.jdbc.core.metadata.CallMetaDataContext]: [Found match for []]
[07 Oct 2014 10:32:49,028] [DEBUG] [org.springframework.jdbc.core.simple.SimpleJdbcCall]: [The following parameters are used for call {call USER.ADD_ADDRESS()} with: {}]
[07 Oct 2014 10:32:49,028] [DEBUG] [org.springframework.jdbc.core.JdbcTemplate]: [Calling stored procedure [{call USER.ADD_ADDRESS()}]]
[07 Oct 2014 10:32:49,028] [DEBUG] [org.springframework.jdbc.datasource.DataSourceUtils]: [Fetching JDBC Connection from DataSource]
[07 Oct 2014 10:32:49,034] [DEBUG] [org.springframework.jdbc.datasource.DataSourceUtils]: [Returning JDBC Connection to DataSource]
[07 Oct 2014 10:32:49,034] [DEBUG] [org.springframework.jdbc.support.SQLErrorCodesFactory]: [Looking up default SQLErrorCodes for DataSource [weblogic.jdbc.common.internal.RmiDataSource@2521ddb8]]
[07 Oct 2014 10:32:49,034] [DEBUG] [org.springframework.jdbc.support.SQLErrorCodesFactory]: [SQLErrorCodes found in cache for DataSource [weblogic.jdbc.common.internal.RmiDataSource@2521ddb8]]
[07 Oct 2014 10:32:49,035] [DEBUG] [org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator]: [Unable to translate SQLException with Error code '6550', will now try the fallback translator]
[07 Oct 2014 10:32:49,035] [DEBUG] [org.springframework.jdbc.support.SQLStateSQLExceptionTranslator]: [Extracted SQL state class '65' from value '65000']
[07 Oct 2014 10:32:49,035] [ WARN] [gproducterr]: [Handler execution resulted in exception]
org.springframework.jdbc.BadSqlGrammarException: CallableStatementCallback; bad SQL grammar [{call USER.ADD_ADDRESS()}]; nested exception is java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'ADD_ADDRESS'ORA-06550: line 1, column :PL/SQL: Statement ignored
但是如果我使用模式名“USER\u DATA”执行相同的代码,其中存在这个过程“USER.ADD\u ADDRESS”,那么它将正确读取元数据信息并执行该过程
我正在使用的用户具有“user\u SCH.user.ADD\u ADDRESS”过程的执行权限
当使用同义词执行任何过程时,我需要做什么更改才能正确读取元数据???您不能为打包过程/函数创建同义词。您可以为以下内容创建同义词:
- 表或对象表
- 视图或对象视图
- 序列
- 存储过程、函数或包
- 物化视图
- Java类模式对象
- 用户定义的对象类型
- 同义词
共享和享受。添加“.WithOutProcedureRecolumnMetadataAccess();”。它将停止spring读取jdbc元数据,并使用您提供的详细信息。有效。你找到答案了吗?