Problem Description: I'm trying to call procedure stored in my database through java code. The procedure I want to call has one parameter with type of 'MAP_VARCHAR' (I have defined it as type in below package).
Now, I'm trying to execute this procedure from my java code however, passing the parameter is giving java.sql.SQLException.
SQL Package to show you how did I create my SQL procedure and type
--------------------------------------------------------
-- Package Body TEST_PACKAGET
--------------------------------------------------------
CREATE OR REPLACE EDITIONABLE PACKAGE BODY "TEST_PACKAGE" AS
PROCEDURE PerformersRole(P_Performer_Map MAP_VARCHAR) AS
BEGIN
DBMS_OUTPUT.PUT_LINE('Hello ' || P_Performer_Map('Engineer'));
END PerformersRole;
END TEST_PACKAGE;
/
--------------------------------------------------------
-- Package TEST_PACKAGE
--------------------------------------------------------
CREATE OR REPLACE EDITIONABLE PACKAGE "TEST_PACKAGE" AS
/* TODO enter package declarations (types, exceptions, methods etc) here */
TYPE MAP_VARCHAR IS TABLE OF VARCHAR(100) INDEX BY VARCHAR(100);
PROCEDURE PerformersRole(P_Performer_Map MAP_VARCHAR);
END TEST_PACKAGE;
/
My java code
public void executeProcedure(){
CallableStatement statement = null;
try {
/// Oracle Connection code should be here
Connection connection = connectionManager.createConnection();
Hashtable newMap = new Hashtable();
newMap.put("Engineer", "Hanson");
newMap.put("Assistant", "Alice Kim");
newMap.put("Supervisor", "James MaCoy");
StringBuffer procedure = new StringBuffer("{call TEST_PACKAGE.PerformersRole(?) }");
statement = connection.prepareCall(procedure.toString());
statement.setInt(1, newMap );
statement.execute();
} catch (Exception ex) {
}
}
The error I'm receiving when I'm executing my java code is
java.sql.SQLException: Invalid column type
at oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:8761)
at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:8259)
at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:9012)
at oracle.jdbc.driver.OracleCallableStatement.setObject(OracleCallableStatement.java:4983)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.setObject(OraclePreparedStatementWrapper.java:230)
What I am missing ?!
Appreciate your help in-advance