Ok, I need some help. I'm frustrated.
I have two stored procs (among many) that work just fine from the MySQL workbench but when I try to run them via a JDBC CallableStatement I ultimately get a SQLException while trying to register output parameters.
Stored Proc #1 is the one I'm trying to call via JDBC. Stored Proc #2 is included because #1 calls it.
I create a CallableStatement with the following JDBC syntax:
"{call _newSimpleMessage(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}"
When I try to register parameter 16 as an output parameter, Connector/J throws an exception complaining that parameter 16 is not an output parameter.
If I swap parameters 16 and 17 the driver still complains.
What am I doing wrong?
Stored Proc #1:
-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `_newSimpleMessage`(
IN scriptRunID INT,
IN parentMessageID INT,
IN threadName TEXT,
IN `level` TEXT,
IN creationTime DATETIME,
IN loggingTime DATETIME,
IN sourceClass TEXT,
IN sourceMethod TEXT,
IN sourceFile TEXT,
IN sourceLine INT,
IN stackTrace TEXT,
IN headline TEXT,
IN additionalInfo TEXT,
IN screenshot BLOB,
IN simpleMessageType TEXT,
OUT messageID INT,
OUT simpleMessageID INT
)
BEGIN
CALL _newMessage(
scriptRunID,
parentMessageID,
threadName,
`level`,
creationTime,
loggingTime,
'SimpleMessage',
sourceClass,
sourceMethod,
sourceFile,
sourceLine,
stackTrace,
messageID
);
INSERT INTO SimpleMessage (
`fk_MessageID`,
`Headline`,
`Additional_Information`,
`Screenshot`,
`fk_SimpleMessageTypeID`
) VALUES (
messageID,
headline,
additionalInfo,
screenshot,
(SELECT SimpleMessageTypeID FROM SimpleMessageType WHERE JavaName = SimpleMessageType)
);
SELECT LAST_INSERT_ID() INTO simpleMessageID;
END
Stored Proc #2:
-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `_newMessage`(
IN scriptRunID INT,
IN parentMessageID INT,
IN threadName TEXT,
IN `level` TEXT,
IN creationTime DATETIME,
IN loggingTime DATETIME,
IN messageType TEXT,
IN sourceClass TEXT,
IN sourceMethod TEXT,
IN sourceFile TEXT,
IN sourceLine INT,
IN stackTrace TEXT,
OUT messageID INT)
BEGIN
INSERT INTO Message (
`fk_ScriptRunID`,
`ParentMessageID`,
`ThreadName`,
`Level`,
`CreationTime`,
`LoggingTime`,
`fk_MessageTypeID`,
`SourceClass`,
`SourceMethod`,
`SourceFile`,
`SourceLine`,
`StackTrace`
) VALUES (
scriptRunID,
parentMessageID,
threadName,
`level`,
creationTime,
loggingTime,
(SELECT MessageType.MessageTypeID FROM MessageType WHERE MessageType.JavaName = messageType LIMIT 1),
sourceClass,
sourceMethod,
sourceFile,
sourceLine,
stackTrace
);
SELECT LAST_INSERT_ID() INTO messageID;
END