2

Hi I am calling an SP from Java code. This SP has 50+ input parameters. So I set ct.setInt(1, id); like this from 1 to 50. So if i need to remove say 4th parameter, i need to change all the numbers manually which is a tedious process. Is there any good way to implement this? Some loop way where we dont need to manually change the parameter number?

4

1 回答 1

2

理想情况下,您可以使用命名参数(我知道这可能不适用于所有数据库/驱动程序)。

或者你可以做

int i = 1;
ct.setInt(i++, id);
//  ct.setObject(i++, old);    // removed line, everything renumbers itself
ct.setString(i++, somethingElse);
ct.setString(i++, evenMore);

跟踪索引。

于 2016-03-16T05:36:21.037 回答