How to Map OraData to Java

Hi
I'm trying to Map Oracle data to Java. Call some procedure which return nested table of object. I'm using thin driver. Here is my code.
type test1 as object
(data1 VARCHAR2(40),data2 varchar2(30));
type test2 IS TABLE OF test1;
procedure test (ven2 out test2);
Test Class:
OracleCallableStatement cstmt = (OracleCallableStatement)con.prepareCall("call Test(?)");
cstmt.registerOutParameter(1,OracleTypes.ARRAY,"TEST2");
cstmt.execute();
ARRAY array = cstmt.getARRAY(1);
Map map = con.getTypeMap();
map.put("SchemaName.TEST1", Class.forName(Test1Type.class.getName()));
// Retrieve array elements
Object[] myObjects = (Object[]) array.getArray();
// Each array element is mapped to MyObj object.
for (int i=0; i<myObjects.length; i++)
Test1Type obj = (Test1Type)myObjects;
Test1Type Class:
import java.sql.SQLException;
import oracle.jdbc.OracleConnection;
import oracle.jdbc.OracleTypes;
import java.sql.SQLData;
import java.sql.SQLInput;
import java.sql.SQLOutput;
import oracle.sql.STRUCT;
import oracle.sql.ARRAY;
import oracle.jpub.runtime.MutableStruct;
public class Test1Type implements SQLData {
public static final String SQLNAME = "SY_VCC.TEST2";
public static final int SQLTYPECODE = OracleTypes.ARRAY;
private String data1;
private String data2;
/* constructor */
public Test1Type ()
public void readSQL(SQLInput stream, String type)
throws SQLException
setData1(stream.readString());
setData2(stream.readString());
public void writeSQL(SQLOutput stream)
throws SQLException
stream.writeString(getData1());
stream.writeString(getData2());
public String getSQLTypeName() throws SQLException
return SQLNAME;
/* accessor methods */
public String getData1()
{ return data1; }
public void setData1(String xdata1)
{ data1 = xdata1; }
public String getData2()
{ return data2; }
public void setData2(String xdata2)
{ data2 = xdata2; }
The Test Class Throws the Exception
java.lang.ClassCastException: oracle.sql.STRUCT
Thanks in advance

This construction is working well, but I can't still remap the STRUCT Object to the Test1Type class.
for (int i=0; i<myObjects.length; i++)
STRUCT myObjects2 = (STRUCT) myObjects;
Object[] Object2 = (Object[])myObjects2.getAttributes();
// Test1Type obj = (Test1Type)myObjects[i];
for (int j=0; j<Object2.length; j++)
System.out.println(Object2[j]);
The line Test1Type obj = (Test1Type)myObjects[i]; is throwing Exception java.lang.ClassCastException: oracle.sql.STRUCT.Do anybody know, if the problem is in the Test1Type class or Test class?

Similar Messages

  • How to map idl to java for "union" type

    help me

    I'm not exactly sure what you're asking for. If you've written IDL that uses an IDL union type, it will be converted to Java when you use your IDL to Java compiler (like idlj), right?
    If you're looking for the specification on how the compiler does/should do it, get the latest IDL to Java language mapping from the OMG -- www.omg.org.

  • How to map wsdl to java in build.xml?

    I write like this it is not working.............
    <target name="generate.java" >
         <taskdef name="wsdl2java"
         classname="org.apache.ws.wsdl2java.WSDL2JavaTask"
         classpathref="axis2.classpath"/>
         <wsdl2java file="http://192.168.4/forums/forumIntegration.php?wsdl"
         outputLocation="${build.dir}" >
         <classpath>
         <pathelement path="${axis2.classpath}"/>
         <pathelement location="${build.dir}/classes"/>
         </classpath>
         </wsdl2java>
         </target>

    Have used the axis ant tasks successfully before with axis 1. Are you using axis two? What kind of errors are you getting?
    Jim

  • How to map javax.xml.datatype.XMLGregorianCalendar to java.util.Calendar

    Hi ,
    How to map javax.xml.datatype.XMLGregorianCalendar to java.util.Calendar so that i can use pass String parameter in YYYY-MM-DD format to my Web service.
    I generated the schema classes using Jaxb 2.1.5.
    Please give suggestion
    Thanks in Advance.

    toGregorianCalendar().getTime()

  • How to execute an ABAP Mapping after a Java Mapping

    Hi, i have found a Bug in XI and SAP said to me that the only solution is to execute an ABAP mapping after my java mapping.
    I have an IDOC to FILE scenario
    Could anyone orient me on what do i have to configure, so after my java mapping i can execute an abap mapping ?.
    Do i have to use process integration?
    thanks
    Mariano.

    i have developed a Java mapping originally, but XI has a bug. When you do not write anything to the outputStream XI instead of writing an emtpy file writes a file containing one byte ( 0x00 ) and this is a problem.
    SAP said to me that they will not fix this issue so they recomend me to create an abap mapping after my java mapping that will send no information if it receives this byte (0x00) and if not it will write all the information as received.
    My doubt regarding putting several mappings in the interface mapping configuration is this...
    Actual configuration:
    SOURCE MSG A -> ORIGINAL MAPPING -> TARGET MSG B
    Proposed configuration
    SOURCE. MSG A -> ORIGINAL MAPPING -> TARGET MSG B
    SOURCE. MSG A -> PATCH MAPPING -> TARGET MSG B
    I dont understand what receives de "patch mapping" it receives the structure from TARGET MSG B?
    regards
    mariano

  • Retrive message mapping error from java class

    Hi,
    I'm trying to create a scenario that if exist an error in the message mapping step this error will be inserted in a Ztable. I'm thinking in to call to the message mapping from a java class to catch the exception and this java class will be used in the interface mapping.
    Is it possible? If yes, How to call the message mapping from java code?
    Exists other possible solution?
    I need to do it because we want store all mapping errors in a Ztable. (Customer requeriment)
    Thanks, in advance
    Jose Manuel

    you can throw generic exceptions from the message mapping like this - /people/michal.krawczyk2/blog/2007/04/26/xipi-throwing-generic-exceptions-from-any-type-of-mapping
    you can then decide how to handle these exceptions

  • How to pass Array of Java objects to Callable statement

    Hi ,
    I need to know how can I pass an array of objects to PL/SQL stored procedure using callable statement.
    So I am having and array list of some object say xyz which has two attributes string and double type.
    Now I need to pass this to a PL/SQL Procedure as IN parameter.
    Now I have gone through some documentation for the same and found that we can use ArrayDescriptor tp create array (java.sql.ARRAY).
    And we will use a record type from SQL to map this to our array of java objects.
    So my question is how this mapping of java object's two attribute will be done to the TYPE in SQL? can we also pass this array as a package Table?
    Please help
    Thanks

    I seem to remember that that is in one of Oracle's online sample programs.
    http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/index.html

  • How to send attachments using java application and outlook

    Hi ,
    I created an application in java which is as
    on the Conference Tab i can schedule a conference and with the send command on page it map all the scheduled data to outlook(with all conference details) and using outlook send option the mails are send to appropriate user.
    but now i want to modify this application such as when i use the send command from my jsp page it should attach the file that is in .vcs or .ics format for auto updation of user calender.
    can any one know how to send attachment using java application .

    Last time I checked, SMS was a service between carriers and doing SMS yourself was really tricky. Some services existed to let you do it but as I recall they wanted non-trivial money.
    However, most phone carriers provide an email-to-SMS bridge of some kind.
    So the easiest thing is just to send an email.
    That's sending from a non-phone to a phone. There's a J2ME library to send/receive SMS from/to a phone.
    However, this is from memory, and a little out of date, so I could be entirely wrong. Hope it helps anyway.

  • How to map a collection of object in TopLink?

    For (simple) example, I've a XSD that defines:
    <xsd:complexType name="AttachmentType">
    <xsd:sequence>
    <xsd:element name="docID" nillable="false" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="MyDocType">
    <xsd:sequence>
    <xsd:element name="attachment" nillable="true" minOccurs="0"
    maxOccurs="unbounded" type="tns:AttachmentType"/>     
    </xsd:sequence>
    </xsd:complexType>
    This XSD is referenced by a WSDL. Using JDeveloper to generate a Java Web Service using the WSDL and will get the following classes:
    public class AttachmentType implements java.io.Serializable
    protected java.lang.String docID;
    public AttachmentType() {    }
    public java.lang.String getDocID() {        return docID;    }
    public void setDocID(java.lang.String docID) {        this.docID = docID;    }
    public class MyDocType implements java.io.Serializable
    protected AttachmentType[] attachment;
    public MyDocType () {    }
    public AttachmentType[] getAttachment() {        return attachment;    }
    public void setAttachment(AttachmentType[] attachment)
    this.attachment = attachment;
    Now I want to generate a XML document from MyDocType. I use TopLink (JAXB) to do the mapping. However, how to map the 'attachment' of type AttachmentType[]? TopLink seems only allowing List/Set/Collection container options.
    Anyone can help?
    Note: I have to use the classes generated from WSDL.
    Thanks!!

    Thanks. I'm using TopLink Workbench for the mapping
    and have no idea on how to specify the XML
    transformation mapping for array attribute. Can you
    tell me more?I was putting together an example of the transformation mapping but came up with a better way. It turns out that a transformation mapping isn't ideal because you have to take over some of the responsibility for converting XML to objects. A better solution is to intercept the calls to the getter and setter for the AttachmentType[] and convert between an Array and List. Just map the Array as a composite collection in the workbench and customize the attachment attribute mapping in code.
    Each mapping in TopLink has Accessor object responsible for getting and setting values in objects. If you choose method or direct access the mapping will have a different Accessor class. So the solution is to use an Accessor that converts the List TopLink builds into an Array of the correct type on set. On get, the Accessor creates a List from the Array.
    You can introduce a custom Accessor using an After Load method. I've put a complete example up on my googlepages account[1]. The key code is listed below. Note that this code assumes you're using direct instance variable access. Also, this code works with TopLink 10.1.3.2 and the TopLink 11 preview. It won't work with previous versions.
    The After Load class that changes the mapping accessor:
    public class MyDocCustomizer {
         public static void customize(ClassDescriptor descriptor) {
              XMLCompositeCollectionMapping mapping = (XMLCompositeCollectionMapping)
                   descriptor.getMappingForAttributeName("attachment");
              InstanceVariableAttributeAccessor existingAccessor =
                   (InstanceVariableAttributeAccessor) mapping.getAttributeAccessor();
              ListArrayTransformationAccessor transformationAccessor =
                   new ListArrayTransformationAccessor(AttachmentType.class, "attachment");
              transformationAccessor.initializeAttributes(descriptor.getJavaClass());
              mapping.setAttributeAccessor(transformationAccessor);
    }The custom InstanceVariableAccessor subclass:
    public class ListArrayTransformationAccessor extends
              InstanceVariableAttributeAccessor {
         private Class arrayClass;
         public ListArrayTransformationAccessor(Class arrayClass, String attributeName) {
              super();
              this.arrayClass = arrayClass;
              this.setAttributeName(attributeName);
         public Object getAttributeValueFromObject(Object anObject)
                   throws DescriptorException {
              Object[] attributeValueFromObject =
                   (Object[]) super.getAttributeValueFromObject(anObject);
              return Arrays.asList(attributeValueFromObject);
         public void setAttributeValueInObject(Object anObject, Object value)
                   throws DescriptorException {
              List collection = (List)value;
              Object[] array = (Object[]) Array.newInstance(arrayClass, collection.size());
              for (int i = 0; i < collection.size(); i++) {
                   Object element = collection.get(i);
                   Array.set(array, i, element);
              super.setAttributeValueInObject(anObject, array);
    }--Shaun
    http://ontoplink.blogspot.com
    [1] http://shaunmsmith.googlepages.com/Forum-519205-OXM-Array.zip

  • Mapping Drive using Java

    Hi All
    currently I'm using windows scripting to map a drive. However, I would like to change to using java program to map a drive. Is there any method or class that I can use to map drive???

    That applies to sreepriyar's first half of the
    question. The last half, " which runs as awindows
    service?" can be answered with a google search.
    http://www.google.com/search?q=java+windows+service
    No, he asks how to map a drive and use in a java
    program which runs as a windows service. That
    indicates that he already has a program that runs as
    a service? So the answer is still the same as the one
    given before?
    /KajI can see how the question could be read that way. The question is ambiguous and only sreepriyar could clarify it.
    The reason I interrupted the question the way I did is because I was give sreepriyar the benefit of the doubt, even though we seem to have a large percentage of inept posters. The all should read something like http://perl.plover.com/Questions.html before posting their first question.
    Funny thing is, even if sreepriyar where to clarify the question at this point, even if he meant it the way you interrupted question, to save face which way do you think sreepriyar would now say he meant the question? :)
    In this case sreepriyar should have stated:
    I read Peter-Lawrey response, but I want to make it a Windows Service. I search for it on the web but there are a bunch of different products that may work. Product A, B, C (with links). Has anyone used the products? Which do you feel is best?

  • How to map n x m to  i

    how to map  all the items to another node (0...unbounded)?
    head (0...unbounded)
      --  t1
        --t2
        --t2
       -- item (0....unbounded)
       i1
       i2
      i3
    Edited by: Shen Peng on Dec 7, 2010 9:28 AM

    Hi Shen,
    If the version of your PI system is less than 7.1, then you need to go for Java mapping to achieve this requirement.
    Here is a smple Java mapping code.
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.AbstractTrace;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    import java.util.Map;
    import java.io.*;
    public class PayloadToXMLField implements StreamTransformation {
        String strXML = new String();
         //Declare the XML tag for your XML message
         String StartXMLTag = "<Payload>";
         String EndXMLTag = "</Payload>";
        AbstractTrace trace;
        private Map param = null;
        public void setParameter(Map param) {
            this.param = param;
        public void execute(InputStream in, OutputStream out) {
            trace =
                (AbstractTrace) param.get(
                    StreamTransformationConstants.MAPPING_TRACE);
            trace.addInfo("Process Started");
            try {
                StringBuffer strbuffer = new StringBuffer();
                byte[] b = new byte[4096];
                for (int n;(n = in.read(b)) != -1;) {
                    strbuffer.append(new String(b, 0, n));
                strXML = strbuffer.toString();
            } catch (Exception e) {
                System.out.println("Exception Occurred");
            outputPayload =
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                   + StartXMLTag
                   + strXML
                   + EndXMLTag;
            try {
                out.write(outputPayload.getBytes());
                   trace.addInfo("Process Completed");;
            } catch (Exception e) {
                trace.addInfo("Process Terminated: Error in writing out payload");;
    If you have PI 7.1, then refer the below link:
    /people/jyothi.anagani/blog/2010/06/17/convert-the-input-xml-to-string-in-pi-71-using-standard-graphical-mapping
    Thanks,

  • How to map the method action return value directly into screen using variables?

    Hi,
    My JDev version is 11.1.1.6.3.
    I have a 'MethodAction' defined in PageDef file, that goes to model layer and return String value. As this needs to be executed during initializing of pageDef, I have also added an 'InvokeAction' for that.
    <executables>
               <invokeAction id="invokeSayHelloId" Refresh="ifNeeded"
                                    Binds="sayHello"/>
               <variableIterator id="variables">
                    <variable Name="Name" Type="java.lang.String"/>
               </variableIterator>
    </executables>
    <bindings>
              <methodAction id="sayHello" InstanceName="HrAMDataControl.dataProvider"
                                     DataControl="HrAMDataControl" RequiresUpdateModel="true"
                                     Action="invokeMethod" MethodName="sayHello"
                                     IsViewObjectMethod="false"
                                     ReturnName="data.HrAMDataControl.methodResults.sayHello_HrAMDataControl_dataProvider_sayHello_result">
                                        <NamedData NDName="pName" NDValue="Michael John" NDType="java.lang.String"/>
             </methodAction>
    </bindings?
    Requirement:
    I want to map the return value of this method action directly into screen by making use of PageDef variables.
    Question:
    I. I need to know how to map this return value direcly as exprssion against PageDef variable.
    2. If Question 1 is achievable, assuming the method action returls List instead of String (I know well it returns 2 items), can I map the 1st Item against Variable 1 and 2nd Item against Variable 2 directly?
    Thanks in Advance.
    Ragu

    Thanks Frank, but If I directly map the MethodAction's result to UI, there are chances where it might get executed whenever I refresh the UIComponent (UIComponent to which the methodAction result is mapped. Isn't so??). Instead, If I invoke the MethodAction using InvokeAction, I can get the control on when it should get invoked (using RefreshCondition). If I assign the variable to UIComponent (Assume I've mapped the method action result to variable using expression), refreshing of UIComponent will not cause any performance issue I feel.
    Correct me If I am wrong.

  • How to map WSDL string to BAPI in IR

    Hi,can any body please let me know how to map the WSDL with XML string(notthe XML structure) to the SAP's BAPI structure. Here the BAPI structure contains tree like structure, and the WSDL(XML with one string) contains one field.
    Thanks
    Kiran

    Hi,
    create a data type for a xml that is
    inside your WSLD string
    create a java or abap mapping which will remove the
    wsld structure so you will only have xml string
    now you can map this string to bapi
    you can do it in one interface mapping
    (you just need two mappings):
    first one - remove the wsld
    second - map xml to bapi
    Regards,
    michal

  • How to Map in SAP      ?

    Hi
    My client is Automobile industry.In the presales process my company delivers the goods to the dealer.On transit the goods are damaged.Instead of returning the goods the dealer him self repairs the goods and sends the credit memo to the company.The company will send the engineer for inspection and give the clearance certificate for the dealer.With reference to this we have to create the credit the customer.
    How to Map it SAP....?
    Plz send me the reply
    Regard's
    Prasad.

    Dear Prasad,
    As you r not taking d goodS back (or dealer is not sending them back) thus it's not a case of a Returns. Also there is no issue with d invoice either thus even Invoice Corrrection Request will not b generated.
    Thus it's a simple case of creating a Credit Memo Request for the required amount i.e the amount claimed 2 b spent by d dealer. This will obviously have a block which can b removed by d engineer who went for inspection (or some1else depending on d working of d organisation). Once the billing block is removed the dealer can b issued a Credit Memo in d usual way.
    Hope it answers ur query.
    regards
    PARAM

  • How do I include a JAVA file in my website  using DreamweaverCC ?

    Hi.  I searched the forums and it seems that all questions relating to JAVA and Dreamweaver elicit zero replies.
    I hope that someone has some direction.  Thanks again.
    I have a JAVA file that I want to include or have run within one of my pages in my WebSite.
    file > new > create > and there is not an option for JAVA but there is one for PHP etc. etc.
    How do I incorporate a java script into my Web Site ?
    I thought that I could just copy the code into the file here - at least to begin with  - but JAVA  runs in the background.
    I am lost
    conceptually
    and I do not know how to go about this task
    structurally.
    Thanks again,
    Regina

    JQuery is a core JavaScript library used by millions of web sites.  It's the "do more & write less code framework."  If you're into re-inventing the wheel every time you need an advanced feature (plugin), feel free to manually code it yourself with JavaScript.  However, you'll need to test & debug your scripts in every conceivable browser and OS before you can be sure it's viable for use on a production site.
    On the other hand, you could use a plugin and be up & running in 5 minutes or less. See the code below.
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>HTML5, with Fancybox2 Viewer</title>
    <!--[if lt IE 9]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <!--LATEST JQUERY CORE LIBRARY-->
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <!--FANCYBOX plugins-->
    <link href="http://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.4/jquery.fancybox.css" rel="stylesheet" media="screen">
    <script src="http://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.4/jquery.fancybox.pack.js"></script>
    <style>
    body {
        background: silver;
        font-family:Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif;
    #wrapper {
        width: 1000px; margin:0 auto;
        background:#FFF;
    /**this styles image container**/
    #thumbs p {
        float: left;
        width: 180px;
        height: 12.5em;
        margin: 10px 22px 0 22px; /**space between containers**/
        padding: 10px; /**space around containers**/
        border: 1px solid silver;
        /**rounded borders**/
        -moz-border-radius: 20px;
        -webkit-border-radius: 20px;
        border-radius: 20px;
        /**this styles caption text**/
        font: italic 14px/1.5 Geneva, Arial, Helvetica, sans-serif;
        color: #666;
        text-align: center;
    /**recommend using same size images**/
    #thumbs img {
        width: 160px; /**adjust width to thumbnail**/
        height: 120px; /**adjust height to thumbnail**/
        margin-bottom: 1.5em;
        opacity: 0.75;
    #thumbs img:hover { opacity: 1.0 }
    /**float clearing**/
    #thumbs:after {
        content: ".";
        clear: left;
        font-size: 0px;
        line-height: 0;
        display: block;
        visibility: hidden;
    </style>
    </head>
    <body>
    <div id="wrapper">
    <h1><a href="http://fancyapps.com/fancybox/">Fancybox2</a> Viewer with images</h1>
    <!--insert thumbnails with links to full size images below-->
    <div id="thumbs">
    <p><a class="fancybox" data-fancybox-group="gallery" href="http://placehold.it/400x320.jpg" title="optional captions"><img src="http://placehold.it/160x120.jpg" alt="Thumbnail 1" /></a> <br />
    Caption 1 </p>
    <p><a class="fancybox" data-fancybox-group="gallery" href="http://placehold.it/400x320.jpg" title="optional captions"><img src="http://placehold.it/160x120.jpg" alt="Thumbnail 2" /></a> <br />
    Caption 2 </p>
    <p><a class="fancybox" data-fancybox-group="gallery" href="http://placehold.it/400x320.jpg" title="optional captions"><img src="http://placehold.it/160x120.jpg" alt="Thumbnail 3" /></a> <br />
    Caption 3 </p>
    <p><a class="fancybox" data-fancybox-group="gallery" href="http://placehold.it/400x320.jpg" title="optional captions"><img src="http://placehold.it/160x120.jpg" alt="Thumbnail 4" /></a> <br />
    Caption 4 </p>
    <!--end thumbs--></div>
    <!--end wrapper--></div>
    <!--FancyBox function code-->
    <script>
    $(document).ready(function() {
        $('.fancybox').fancybox();
    </script>
    </body>
    </html>
    Nancy O.

Maybe you are looking for

  • Can I use BAPI_ACC_DOCUMENT_POST for customer clearing(inter company)?

    Hi, We were getting errors for object type. Object type is a mandatory field and it is not taking "BKPFF",  "VBRK" and other object key as a valid object key( Check is present in SAP Include LACC9F20 for object type). We have created a new object typ

  • Cannot install Yosemite on my Macbook pro 13"

    13" Macbook Pro Aluminum model 2.4 processor speed 4 gigs ram 250 gig HD, on IOS 10.6.8. I have read the pre reqs for Yosemite but when im bout to choose which HD ( which is obviously one ) it says "You cannot install Yosemite here", and thats it. Iv

  • How do I sync Iphone 5 to new MacBook Pro without deleting what's on iPhone?

    I just purchased a new MacBook Pro and I have an iPhone 5 that has been synced with my PC.  When I try and sync the iPhone with the new MacBook ti tells me that it will erase what is on the iPhone and replace it with what is on the MacBook.  I want t

  • Unix domain sockets: How to name them? And where to put them?

    I am using unix sockets for inter-process communication in a C++/gtkmm project. Are there naming conventions and conventions about where to place sockets in the filesystem? In all example code I found, dummies like /home/user/mysocket were being used

  • When jobs are not posting it show error?

    Hi All, We have requirement, when particular jobs are not posting(E-recruitment), it should give a warning message. Is it possible. If yes, Could you please advise. Regards BTM