IBM Websphere门户网站服务器中的非封闭oracle连接

时间:2022-04-11 17:35:33

We are facing unpredictable error saying that 'missing in or out parameter at index:7' for a procedure call using Callable statement in Java. On each procedure call we are not closing the connection. Does this is the problem?

我们正面临着不可预测的错误,即在Java中使用Callable语句进行过程调用时,“在index:7处缺少输入或输出参数”。在每个过程调用中,我们都没有关闭连接。这是问题吗?

Note: Code implementation is not direct code, which calls procedure. We have internal framework that takes care of DB call So Its difficult to post complete code.

注意:代码实现不是直接代码,它调用过程。我们有内部框架负责DB调用所以很难发布完整的代码。

2 个解决方案

#1


1  

Lacking a code snippet (it would be helpful if you can post it) we can only speculate about possible causes. One thing to point out with inout parameters is that you need to both set input values for them, statement.setX(n,value) and register them as output parameters, statement.registerOutParameter(n,type) each time they are used. Refer to this link from Oracle JDBC documentation for a more complete example:

缺少代码片段(如果您可以发布它会很有帮助)我们只能推测可能的原因。使用inout参数指出的一点是,您需要为它们设置输入值,statement.setX(n,value),并在每次使用它们时将它们注册为输出参数,statement.registerOutParameter(n,type)。有关更完整的示例,请参阅Oracle JDBC文档中的此链接:

http://docs.oracle.com/javadb/10.10.1.2/ref/rrefjdbc75719.html

You will also want to be aware the WebSphere Application Server data sources cache CallableStatements by default (upon CallableStatement.close), which involves invoking the CallableStatement.clearParameters which has the effect of clearing the parameter values and releasing resources held by them. It is possible that it might also clear the registration of out parameters. To experiment with disabling the statement cache, configure statementCacheSize=0 on the data source. Alternately, if using JDBC 4.0 or higher, an individual statement can be made non-cacheable via CallableStatement.setPoolable(false). To be clear, I'm not recommending disablement of statement caching as a solution, only as an experiment to help you narrow down the cause.

您还需要了解WebSphere Application Server数据源默认情况下缓存CallableStatements(在CallableStatement.close上),这涉及调用CallableStatement.clearParameters,它具有清除参数值和释放它们所拥有的资源的效果。它可能还可以清除out参数的注册。要试验禁用语句高速缓存,请在数据源上配置statementCacheSize = 0。或者,如果使用JDBC 4.0或更高版本,则可以通过CallableStatement.setPoolable(false)使单个语句不可缓存。要明确的是,我不建议禁用语句缓存作为解决方案,只是作为帮助您缩小原因的实验。

#2


0  

Unless you are creating a connection yourselves, you do not need to close the connection. However, you do need to close the CallableStatement.

除非您自己创建连接,否则无需关闭连接。但是,您需要关闭CallableStatement。

Also, missing in or out parameter is an indication that the procedure requires more parameters bound to it when compared to the number or parameters specified in the callable statement.

此外,缺少in或out参数表示与可调用语句中指定的数字或参数相比,该过程需要更多参数绑定到该参数。

If the above is not the case, then you might be getting it because you are not binding a parameter in the statement.

如果不是这种情况,那么您可能会得到它,因为您没有绑定语句中的参数。

Example:

call MY_PROC(?,?)

you need to bind 2 parameters in java code for it. But as you are saying that it does not happen always, maybe one of your parameter binding is in an if condition that is not satisfied when the error occurs.

你需要在java代码中绑定2个参数。但正如你所说的那样,它总是不会发生,也许你的参数绑定之一是在if条件下,当错误发生时不满足。

#1


1  

Lacking a code snippet (it would be helpful if you can post it) we can only speculate about possible causes. One thing to point out with inout parameters is that you need to both set input values for them, statement.setX(n,value) and register them as output parameters, statement.registerOutParameter(n,type) each time they are used. Refer to this link from Oracle JDBC documentation for a more complete example:

缺少代码片段(如果您可以发布它会很有帮助)我们只能推测可能的原因。使用inout参数指出的一点是,您需要为它们设置输入值,statement.setX(n,value),并在每次使用它们时将它们注册为输出参数,statement.registerOutParameter(n,type)。有关更完整的示例,请参阅Oracle JDBC文档中的此链接:

http://docs.oracle.com/javadb/10.10.1.2/ref/rrefjdbc75719.html

You will also want to be aware the WebSphere Application Server data sources cache CallableStatements by default (upon CallableStatement.close), which involves invoking the CallableStatement.clearParameters which has the effect of clearing the parameter values and releasing resources held by them. It is possible that it might also clear the registration of out parameters. To experiment with disabling the statement cache, configure statementCacheSize=0 on the data source. Alternately, if using JDBC 4.0 or higher, an individual statement can be made non-cacheable via CallableStatement.setPoolable(false). To be clear, I'm not recommending disablement of statement caching as a solution, only as an experiment to help you narrow down the cause.

您还需要了解WebSphere Application Server数据源默认情况下缓存CallableStatements(在CallableStatement.close上),这涉及调用CallableStatement.clearParameters,它具有清除参数值和释放它们所拥有的资源的效果。它可能还可以清除out参数的注册。要试验禁用语句高速缓存,请在数据源上配置statementCacheSize = 0。或者,如果使用JDBC 4.0或更高版本,则可以通过CallableStatement.setPoolable(false)使单个语句不可缓存。要明确的是,我不建议禁用语句缓存作为解决方案,只是作为帮助您缩小原因的实验。

#2


0  

Unless you are creating a connection yourselves, you do not need to close the connection. However, you do need to close the CallableStatement.

除非您自己创建连接,否则无需关闭连接。但是,您需要关闭CallableStatement。

Also, missing in or out parameter is an indication that the procedure requires more parameters bound to it when compared to the number or parameters specified in the callable statement.

此外,缺少in或out参数表示与可调用语句中指定的数字或参数相比,该过程需要更多参数绑定到该参数。

If the above is not the case, then you might be getting it because you are not binding a parameter in the statement.

如果不是这种情况,那么您可能会得到它,因为您没有绑定语句中的参数。

Example:

call MY_PROC(?,?)

you need to bind 2 parameters in java code for it. But as you are saying that it does not happen always, maybe one of your parameter binding is in an if condition that is not satisfied when the error occurs.

你需要在java代码中绑定2个参数。但正如你所说的那样,它总是不会发生,也许你的参数绑定之一是在if条件下,当错误发生时不满足。