Reputation: 7665
I am calling this Oracle Stored Procedure using Spring SimpleJdbcCall
The code is throwing "Caused by: java.sql.SQLException: Invalid column type: 1111"
org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback;
uncategorized SQLException for SQL [{call O_XEROX_PRNT_PRT(?, ?)}]; SQL state [99999]; error code [17004]; Invalid column type: 1111;
nested exception is java.sql.SQLException: Invalid column type: 1111
Here is the stored Procedure, I tried to simplify it as much as I can for testing. so Its doing nothing but randomizing some values and returning random message,
The Stored Procedure is executing fine from SqlDeveloper...
CREATE OR REPLACE PROCEDURE O_XEROX_PRNT_PRT
(
CLIENT_KEY IN VARCHAR2
,P_STATUS IN VARCHAR2
-- OUTPUT back to java
, O_STATUS OUT BOOLEAN
, O_MESSAGE OUT VARCHAR2
) AS
PROC_STATUS BOOLEAN;
PROC_ERROR_MESSAGE VARCHAR2(4000);
rand_num number;
BEGIN
dbms_output.put_line('O_XEROX_PRNT_PRT ');
select round(dbms_random.value(1,10)) into rand_num from dual;
IF rand_num > 8 THEN
PROC_STATUS := TRUE;
PROC_ERROR_MESSAGE := 'ALL IS GOOD';
ELSE
PROC_STATUS := FALSE;
PROC_ERROR_MESSAGE := 'SOMTHING WENT WRONG!!! ';
END IF;
END O_XEROX_PRNT_PRT;
Java code I am using:
String CLIENT_KEY = 'CLIENT_KEY val';
String P_STATUS = 'Printer works';
Boolean O_STATUS =true;
String O_MESSAGE ;
JdbcTemplate template = new JdbcTemplate(printerHubPortalDS);
SimpleJdbcCall jdbcCall = new SimpleJdbcCall(template).withProcedureName("O_XEROX_PRNT_PRT")
.declareParameters(
new SqlParameter(CONST_CLIENT_KEY, Types.VARCHAR),
new SqlParameter(CONST_P_STATUS , Types.VARCHAR),
);
MapSqlParameterSource paramMap = new MapSqlParameterSource()
.addValue(CONST_CLIENT_KEY,CLIENT_KEY)
.addValue(CONST_P_STATUS ,P_STATUS );
//This line is throwing the error
Map<String, Object> resultMap = jdbcCall.execute(paramMap);
String tmp = (String)resultMap.get(CONST_O_STATUS);
O_STATUS = Boolean.valueOf(tmp);
O_MESSAGE = (String) resultMap.get(CONST_O_MESSAGE);
Upvotes: 0
Views: 1809
Reputation: 457
It looks like you haven't defined the output parameters in the declaredParameters
.
Adding the following under the current SqlParameter
should solve the error.
new SqlOutParameter("O_STATUS", Types.BOOLEAN),
new SqlOutParameter("O_MESSAGE", Types.VARCHAR)
Upvotes: 1