MySQL Forums
Forum List  »  Connector/JDBC and Java

registerOutParameter not working when some parameters pre-populated
Posted by: Nigel Maddocks
Date: January 25, 2006 09:39AM

callStmt.registerOutParameter(1, java.sql.Types.INTEGER);

falls over with "Parameter number 1 is not an OUT parameter"

The procedure definition is:
PROCEDURE `employee_surname_count`(surname VARCHAR(50), OUT surname_count INT)
SELECT COUNT(*) INTO rtn FROM employee e WHERE e.surname=surname;
SET surname_count = rtn;

String lclRunSQL= "{CALL employee_surname_count('Jones', ?)}"
callStmt = conn.prepareCall(lclRunSQL);

callStmt .getParameterMetaData().getParameterCount(); --- reports 1 (one).

I appreciate that I'm not supplying all parameters as question marks "?" to the prepared statement, but the jdbc driver is reporting the parameterCount as 1 - which is fine by me.

The works OK in MS SQL Server and Oracle.

If I redefine the PROCEDURE as (OUT surname_count INT, surname VARCHAR(50)) (i.e. reverse the parameters)
and prepare it using lclRunSQL= "{CALL employee_surname_count(?, 'Jones')}"
then all is OK.
I would regard the problem I'm encountering as an error in MySQL. In any case, MySQL is not being self-consistent.

Using MySQL version 5.0.18, Java 1.5.0_04, Tomcat 5.5.9, Windows XP Pro SP2.

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.