HELP! Unsuccessful using JPublisher generated file
Date: 24 Oct 2001 06:57:00 -0700
Message-ID: <f7b19882.0110240557.c030633_at_posting.google.com>
Working with oracle 8i on Soloaris: My stored procedure written in java expects an oracle object (named outer_objtyp) which contains two fields. One field is another oracle object(inner_objtyp) and the other field is a varchar2. I did jpublisher on the Inner_Objtyp and Outer_Obtyp,loaded these java classes to oracle, and type mapped these java classes to the proper corresponding oracle object. When I do jpub using the -usertypes=oracle option everything works well and the stored procedure is executed properly. But when I do jpub using -usertypes=jdbc, upon executing the stored procedure, I get an Inconsistent Datatype error (and a class cast exception too.) I don't know what I need to do in order to get the usertypes=jdbc to work correctly. WHAT DID I LEAVE OUT? What am I missing? Here's the syntax:
THE ORACLE OBJECT:
CREATE TYPE inner_objtyp AS OBJECT(inner_fld VARCHAR2(25))
CREATE TYPE outer_objtyp AS OBJECT
(inner_obj inner_objtyp,outer_fld VARCHAR2(25))
THE STORED PROCEDURE'S PUBLICATION:
CREATE OR REPLACE PACKAGE sub_clss_proc AS
PROCEDURE proc_sub_clss
(outer2 IN OUTER_OBJTYP
);
END sub_clss_proc;
/
CREATE OR REPLACE PACKAGE BODY sub_clss_proc AS PROCEDURE proc_sub_clss
(outer2 IN OUTER_OBJTYP )
AS LANGUAGE JAVA
NAME 'SubClssProc.procOuter(Outer_Objtyp)'; END sub_clss_proc;
/
JPUB STATMENT THAT WORKS:
jpub -user=$SIGNON \
-sql=inner_objtyp:Inner_Objtyp,outer_objtyp:Outer_Objtyp \
-case=mixed -methods=none \
-usertypes=oracle
JPUB STATEMENT THAT CAUSES INCONSISTENT DATA ERROR:
jpub -user=$SIGNON \
-sql=inner_objtyp:Inner_Objtyp,outer_objtyp:Outer_Objtyp \
-case=mixed -methods=none \
-usertypes=jdbc
I'd like to add the stored procedure's code to the original question. It might be helpful to anyone that's trying to help me.The type mapping written there. Maybe I left out something in the type mapping.
//THE STORED PROCEDURE
import java.sql.*;
import Inner_Objtyp;
import Outer_Objtyp;
public class SubClssProc
{
public static void procOuter(Outer_Objtyp outerObj) throws Exception
{
Connection conn = new
oracle.jdbc.driver.OracleDriver().defaultConnection();
try {
// DB MAPPING java.util.Map map = conn.getTypeMap(); map.put("MACH_ADMN.OUTER_OBJTYP", Class.forName("Outer_Objtyp")); map.put("MACH_ADMN.INNER_OBJTYP", Class.forName("Inner_Objtyp")); conn.setTypeMap(map); System.out.println("Here1"); System.out.println("outerObj.outer_fld " + outerObj.getOuterFld() + "outerObj.innerObj.inner_fld " + outerObj.getInnerObj().getInnerFld());}
catch (Exception e) {
if (e instanceof SQLException) System.out.println( String.valueOf( ((SQLException)e).getSQLState() );
e.printStackTrace(); System.out.println("Message: " + e.getMessage()); } // End Catch } // End Method } // End Class
Please respond ASAP. Thanx. Received on Wed Oct 24 2001 - 15:57:00 CEST