...
// Create a Callable statement object and cast it
ocstmt =(OracleCallableStatement)conn.prepareCall(
" begin"+
" cityinfo_pkg.populate_Index_By_tbl();"+
" cityinfo_pkg.retrieve_All_Cities(?,?,?,?);"+
" end;");
// Index-By Table can be registered using registerIndexTableOutParameter
ocstmt.registerIndexTableOutParameter(1,maxTablLen,OracleTypes.INTEGER,0);
// Register the out parameter of the index by table
for the 2nd parameter
// It returns an array of city names in the form of string
ocstmt.registerIndexTableOutParameter(2,maxTablLen,OracleTypes.VARCHAR,eleMaxLen);
// Register the out parameter of the index by table
for the 3rd parameter
// It contains an array of population corresponding to each city
ocstmt.registerIndexTableOutParameter(3,maxTablLen,OracleTypes.INTEGER,eleMaxLen);
// Register the out parameter of the index by table
for the 4th parameter
ocstmt.registerIndexTableOutParameter(4,maxTablLen,OracleTypes.VARCHAR,eleMaxLen);
// Execute the callable statement.
ocstmt.execute();
// Index By Table sent as OUT parameter of a
procedure can be retrieved
// as Java primitive array using
// synchronized public Object getPlsqlIndexTable
// (int paramIndex, Class primitiveType) throws SQLException
// where paramIndex is the index of the OUT parameter and
// primitiveType - Class of the OUT parameter datatype in java
cityIdArray = (int[])
ocstmt.getPlsqlIndexTable(1,java.lang.Integer.TYPE);
// Retrieve the array of name of the cities present
in Index-by table
cityNameArray = (String[])
ocstmt.getPlsqlIndexTable(2);
// Retrieve the population of the cities present as
integer in
// index-by table
populationArray = (int[])
ocstmt.getPlsqlIndexTable(3,java.lang.Integer.TYPE);
....