I have a stored procedure that invokes the SQL "return (42)" at the point of completion. (This is Sybase if that makes any difference.) The following is the JDBC I put together to call the stored procedure. The three method calls that use and index work, the three commented out lines that use the column name do not. I have a strong need to be able to use the column name version for flexibility with other stored procedures that have very long parameter lists of which only a subset is needed. If I try to use the index version for argument one, and the named version for the remainder I get a run time error saying that I can't mix them. Actually, the name version runs but it appears that arguments are shifted when they get to the stored procedure. I've tried all sorts of permutations of the registerOutParameter() line, but no luck.
Any insights you could give me would be appreciated.
As far as I know, pure JDBC doesn't support named parameters. You have to use the question marks for all parameters.
Some JDBC drivers have methods that allow to use named parameters, but this is an extension incompatible with JDBC standard, so it won't work with another JDBC driver.
Edit: the original question concerned passing function/procedure parameters by name. I don't know whether that is supported as part of the JDBC standard, I always pass parameters by position - that always works.