Simple serialization question with objects

Hi, I'm really new to the whole concept of serialization and what I want to do is create a blackjack game that can have up to 4 people playing, connected to a server that will act as the dealer. I need to be able to serialize some objects from the players to the server and have the server make some changes then send the objects back.
However every example I've run across dealing with something of this nature involves writing to a file so I'm not sure what the code to do this would look like.
My best guess would be ObjectInputStream and ObjectOutputStream but I don't understand how I can tell these streams that I just want to send the serialized object back and forth.
If anyone could explain to me a bit better how these streams work, or show me roughly what the code might look like, I would really appreciate it.

It doesn't matter whether you write to a file or a socket or a byte array or whatever. That stuff is what's under the ObjectOutputStream. When you create the OOS, you wrap it around some other stream (e.g. a FileOutputStream in the examples you're talking about I guess). To send something to a server, you'd instead just wrap it around the OutputStream of a Socket that's talking to that server. Everything else is the same.
Whether you use raw sockets or some other means is up to you, but that's completely separate from the serialize/deserialize process.
http://java.sun.com/docs/books/tutorial/essential/io/index.html
http://java.sun.com/docs/books/tutorial/networking/sockets/index.html

Similar Messages

  • Simple Serializable demo with problems

    Hello!
    I am having a very simple demo where I tried to see how the Serializable interface works. However, I am receiving message NotSerializableException. What's wrong?
    Thanks in advance!
    Kind regards,
    Igor
    Here's the demo:
    import java.io.*;
    public class SerializationDemo {
      private class Data implements Serializable {
        String someString = "This is a string";
        double someDouble = 1;
      public SerializationDemo() {
        try {
          FileOutputStream fos = new FileOutputStream("dataObjectSerialized");
          ObjectOutputStream oos = new ObjectOutputStream(fos);
          oos.writeObject(new Data());
          fos.close();
        catch (Exception e) {
          System.out.println(e.toString());
      static public void main(String args[]) {
        SerializationDemo demo = new SerializationDemo(); 
    };

    Consider the following code. What do you expect Child.foo() to print? Why? Supposing you made it serializable, how would you expect it to behave when deserialized?
    public class Illustration {
       public Illustration(int x) {
          this.x = x;
          this.c = new Child();
       public void foo() {
          c.foo();
       private Child c;
       private int x;
       private class Child {
          public Child() {
          public void foo() {
             System.out.println(x);
       public static void main(String[] argv) {
          Illustration i = new Illustration(42);
          i.foo();
    }In case that's not clear, here's a quick illustration:
    public class Illustration {
       public class Child { ... }
    +--------------+
    | Illustration |
    |              |
    |  +-----+     |
    |  |Child|     |
    |  +-----+     |
    |              |
    +--------------+
    public class Illustration {
       public static class Child { ... }
    +--------------+
    | Illustration |    +-----+
    |              |--->|Child|
    |              |    +-----+
    |              |
    |              |
    |              |
    +--------------+Because Child is not declared static, it has full access to all of the fields of Illustration. Therefore if you serialize it in order to work after deserialization as it did before, it must have copies of all of the owning class's fields.
    When you declare it static you break this relationship and it becomes independent.
    So taking your following question:
    Why is this so? Does this mean that the following two statements would produce completely identical results, providing that SerializationDemo class was made Serializable:
    oos.writeObject(new Data());
    oos.writeObject(this);No, not quite - the first form creates a new Data object, serializes that, then (of necessity) serializes the owning class as well.
    The second form just serializes the current class - since it doesn't have an associated Data object, nothing else gets serialized.
    To achieve the effect you want, either make your Data class static, or declare it in its own file (which is roughly the same thing).
    Dave.

  • Binary search question with objects

    Hi
    I have a class called MyClass which is as below
    public class MyClass
    String from;
    String to;
    double d;
    // with getter and setter method
    }I create a ArrayList of MyClass,
    List<MyClass> list = new ArrayList();
    list.add(myClass);
    //add about 8000 myClass object from database; I want to do a search for object from, to;
    I have been doing
    for(MyClass myClass:list)
    if(myClass.equals(from) && myClass.equals(to))
    return myClass;
    }Rather i would like to do a randomSearch, how can i do it,
    will it be faster, then going through all the list
    Any ideas

    Binary search requires that your list is sorted, so you'll have to implement Comparable<MyClass>, and use Collections.sort(list) before doing the search.
    I also think that this:
    if(myClass.equals(from) && myClass.equals(to))implies that you aren't using equals() properly. I think it should look more like this:
    if(myClass.getFrom().equals(from) && myClass.getTo().equals(to))Here's a quick and dirty example of implementing Comparable and doing a binary search:
    static class MyClass implements Comparable<MyClass> {
         private String from, to;
         public MyClass(String from, String to) {
              this.from = from;
              this.to = to;
         public String getFrom() { return from; }
         public String getTo() { return to; }
         public int compareTo(MyClass obj) {
              int toComp = to.compareTo(obj.getTo());
              int fromComp = from.compareTo(obj.getFrom());
              return toComp - fromComp;
         public boolean equals(Object obj) {
              if (obj instanceof MyClass == false) {
                   return false;
              return ((MyClass)obj).getFrom().equals(from) && ((MyClass)obj).getTo().equals(to);
         public int hashCode() {
              return from.hashCode() + to.hashCode();
         public String toString() {
              return "from: "+from+", to: "+to;
    public static void main(String[] args) {
         int num = 5;
         List<MyClass> tests = new ArrayList<MyClass>();
         for (int i = 0; i < num; ++i) {
              MyClass test = new MyClass(i+"", (i*2)+"");
              tests.add(test);
         Collections.sort(tests);
         for (MyClass test : tests) {
              System.out.println(test);
         MyClass theTest = new MyClass("4", "8");
         int index = Collections.binarySearch(tests, theTest);
         MyClass result = tests.get(index);
         System.out.println("index: "+index+", result: "+result);
    }Hope that helps.

  • Error in simple Tutorial? With(object) gives undifined..

    Hello, I got this from an tutorial, but when i run this
    the
    trace(person1.address.street);
    gives undifined ? How come this is undifined and
    trace(person1.address.test);
    is not? ..looks like the With( ...) does not work?
    here is the script:
    person1 = new Object();
    person1.address = new Object();
    person1.address.test = "hello";
    with(person1.address) {
    street = "123 Main Street";
    city = "Boston";
    state = "MA";
    zip = "02114"; }
    trace(person1.address.street);
    trace(person1.address.test);

    "To set a variable inside a with statement, you must have
    declared the variable outside the with statement, or you must enter
    the full path to the Timeline on which you want the variable to
    live. If you set a variable in a with statement without declaring
    it, the with statement will look for the value according to the
    scope chain. If the variable doesn't already exist, the new value
    will be set on the Timeline from which the with statement was
    called."
    ie, street is defined on the timeline that contains that
    code.

  • Simple tiny Question, with terminal

    When you do the unix command *sudo rm -ri* (delete info on all drives), as Mac OS X eats itself, When it deletes Applications, terminal will be still open, and when it deletes the whole system and everything, the dock, menubar, icons, are still intact so what kind of method does it do to delete files? _something different: I've heard that if you open a document with an application (word opening: example.doc), delete the file using secure empty trash, the file will be still open, but once you close the window, you can never open it again._

    CrazyFreak wrote:
    something different: I've heard that if you open a document with an application (word opening: example.doc), delete the file using secure empty trash, the file will be still open, but once you close the window, you can never open it again.
    Well, you wouldn't even need to use "Secure Empty Trash". Just putting the file into the trash and emptying it would be enough. As long as the file's contents are in memory, you can do what you want with it (except save it, since you're likely to get a "File not found" error when the application can't find the original file). Then, if you close the file without saving it to a new file, it'll be gone forever, just as it would if you closed the window and dragged it to the trash and emptied the trash.
    charlie

  • Question with object arrays..

    This is my code and it doesn't seem to be working properly
    public class familymember {
    public familymember(){
    Object[] array=new Object[500];
         public static void main(String args[]) {
         familymember array2 = new familymember();
         array2.array[51] = "500";
              System.out.println( array2.array[51]);
    I get the error message
    Error : No variable array defined in class familymember.
    familymember.java line 15 array2.array[51] = "500";
    What am i doing wrong?

    array cannot be accessed from outside it's block (in this case the constructor).
    just change your code this way:
    public class familymember {
      private Object[] array; // or public or protected or whatever you want
      public familymember(){
        array=new Object[500];
      public static void main(String args[]) {
        familymember array2 = new familymember();
        array2.array[51] = "500";
        System.out.println( array2.array[51]);
    }

  • Simple movie question with my I pod

    I have two movies in my Ipod and have had no problems with anything. But I would like to put new movies on and take these off. I don't want to lose them. What is the procedure for moving them for some sort of storage and then bringing them back if I want to watch them? thank you for any ideas

    You should have your movies in your iTunes library and then you can sync which ones you want onto your ipod.

  • Using Simple Transformations with Objects tt:copy .. results in Exception

    Question:
    How can I serialize an ABAP-Object-Instanz with my own simple transformation?
    In the sap-documentation I found the following solution for the serialisation of any data-objects.
    "z_steffens_simple_transf":
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
      <tt:root name="ROOT"/>
      <tt:template>
        <root>
          <tt:copy ref="ROOT"/>
        </root>
      </tt:template>
    </tt:transform>
    Following the example I wrote this report:
    report  zspahr_test_simple_transf.
    class serializable definition.
      public section.
        interfaces if_serializable_object.
        data attr type string value 'Attribute'.
    endclass.         
    method main_serializable.
        data: oref type ref to serializable,
              xmlstr type xstring.
        create object oref.
        call transformation id
          source root = oref
          result xml xmlstr.
        call function 'DISPLAY_XML_STRING'
          exporting
            xml_string = xmlstr.
        call transformation z_steffens_simple_object
          source root = oref
          result xml xmlstr.
        call function 'DISPLAY_XML_STRING'
          exporting
            xml_string = xmlstr.
      endmethod.                    "main_
    start-of-selection.
      demo=>main_serializable( ).
    Executing this report leads to an exception "CX_SY_REF_NOT_SUPPORTED".
    The "standard" transformation "ID" ist working an translates my object-instance into an asXML representation:
      <?xml version="1.0" encoding="utf-8" ?>
    - <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    - <asx:values>
      <ROOT href="#o3" />
      </asx:values>
    - <asx:heap xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:abap="http://www.sap.com/abapxml/types/built-in" xmlns:cls="http://www.sap.com/abapxml/classes/global" xmlns:dic="http://www.sap.com/abapxml/types/dictionary">
    - <prg:SERIALIZABLE xmlns:prg="http://www.sap.com/abapxml/classes/program/ZSPAHR_TEST_SIMPLE_TRANSF" id="o3">
    - <local.SERIALIZABLE>
      <ATTR>Attribute</ATTR>
      </local.SERIALIZABLE>
      </prg:SERIALIZABLE>
      </asx:heap>
      </asx:abap>
    How can I do this with my own Simple Transformation "ZSPAHR_TEST_SIMPLE_TRANSF" ?
    I want to serialize my object using my own xml-structure, not the asXML-structure !
    Regards
    Steffen

    Hi,
    try like this,i think it may help you.
    ABAP:
    CALL TRANSFORMATION ztrans_test
          SOURCE
               root = partab
         RESULT XML lv_xstring.
    Trnsformation:
    <tt:root name="ROOT" type="?"/>
    <tt:template>
    <VALUES>
    <VALUE_SOURCE>
            <tt:value ref=".ROOT"/>
    </VALUE_SOURCE>
    <VALUE_PARAM>
    <tt:value ref="NAME"/>
    <tt:value ref="VALUE"/>
    </VALUE_PARAM>
    </VALUES>
    Thanks,
    Rajesh.

  • Object Serialization Question.

    Hello, I'm working on a MUD client and I have a DataHolder class to store settings. I'm having problems getting the serialization process to work properly, could someone please give me an example of how to serialize this class and then restore it again? I would like to save the class as "prefs.ser" Here is an example class to use:
    import java.awt.*;
    import java.net.*;
    import java.io.*;
    public class DataHolder
         public Color foreground = Color.black;
         public Color background = Color.yellow;
    // i dont want to save the socket info since it will change many times during actual operation
    // also i know you have to catch the exception from the socket creation : )
         public transient Socket socket = new Socket("lordsoftherealm.org", 1234);
         public DataHolder()
         public setColors(Color foreground, Color background)
              // set background and foreground colors
              // the actual class include methods to retrieve colors, sockets, and other relevent data
              this.foreground = foreground;
              this.background = background;
         public Socket getSocket()
              return socket;
    }Thank you for your time in helping me,
    Joeyford1

    Try this,
    I am using this method to serializeand deserialize my objects ..
    import java.util.Date;
    import java.math.BigDecimal;
    import java.io.*;
    * This object compliments MyObjectTranslator and provides a method to translate
    * any object into a type the database engine can process.
    public class MyObjectTranslator {
    public static Object translate(Object ob) {
    if (ob == null ||
    ob instanceof NullObject ||
    ob instanceof String ||
    ob instanceof BigDecimal ||
    ob instanceof Date ||
    ob instanceof ByteLongObject ||
    ob instanceof Boolean) {
    return ob;
    else if (ob instanceof Serializable) {
    return serialize(ob);
    else {
    // System.out.println("Ob is: (" + ob.getClass() + ") " + ob);
    System.out.println("Unable to translate object. " +
    "It is not a primitive type or serializable.");
    * Serializes the Java object to a ByteLongObject.
    public static ByteLongObject serialize(Object ob) {
    try {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream ob_out = new ObjectOutputStream(bout);
    ob_out.writeObject(ob);
    ob_out.close();
    return new ByteLongObject(bout.toByteArray());
    catch (IOException e) {
    System.out.println("Serialization error: " + e.getMessage());
    * Deserializes a ByteLongObject to a Java object.
    public static Object deserialize(ByteLongObject blob) {
    if (blob == null) {
    return null;
    else {
    try {
    ByteArrayInputStream bin =
    new ByteArrayInputStream(blob.getByteArray());
    ObjectInputStream ob_in = new ObjectInputStream(bin);
    Object ob = ob_in.readObject();
    ob_in.close();
    return ob;
    catch (ClassNotFoundException e) {
    System.out.println("Class not found: " + e.getMessage());
    catch (IOException e) {
    System.out.println("De-serialization error: " + e.getMessage());
    so if you want it to translate it use it something like :
    private Object translateObjectType(Object ob) {
    return MyObjectTranslator.translate(ob);
    and when you wana retrive it use it like :
    Object ds = MyObjectTranslator .deserialize((ByteLongObject) ob);

  • Simple test case with NL and table order .

    Hi,
    did some tests on my 9.2.0.8 and got few questions:
    SQL> select count(*)  from p;
      COUNT(*)
          2000
    SQL> select count(*)  from c;
      COUNT(*)
          1000
    SQL> select count(*) , id from p group by id having count(*) > 1;
    no rows selected
    SQL> select count(*) , id from c group by id having count(*) > 1;
      COUNT(*)         ID
           100         10
    SQL> desc p
               Name
        1      ID number
        2      FILLER varchar2(100)
    SQL> desc c
               Name
        1      ID number
        2      FILLER varchar2(100)
    Got 10046 traces:
    case A
    select /*+ use_nl(p) leading(c) */ *
    from
    p , c where p.id = c.id and c.id in (10)
    Rows     Row Source Operation
        100  TABLE ACCESS BY INDEX ROWID P
        201   NESTED LOOPS
        100    TABLE ACCESS BY INDEX ROWID C
        100     INDEX RANGE SCAN C_ID (object id 411255)
        100    INDEX RANGE SCAN P_ID (object id 411256)
    Case B optimal
    select /*+ use_nl(c) leading(p) */ *
    from
    p , c where p.id = c.id and c.id in (10)
    Rows     Row Source Operation
        100  TABLE ACCESS BY INDEX ROWID C
        102   NESTED LOOPS
          1    TABLE ACCESS BY INDEX ROWID P
          1     INDEX RANGE SCAN P_ID (object id 411256)
        100    INDEX RANGE SCAN C_ID (object id 411255)So its simple nested loop with postponed inner table access .
    Why in row source operation we have got 102 rows (NL level) ? (It means NL was executed 102 times ?)
    And why 201 in other case ?
    Regards
    GregG

    I am not sure about the calculation/reason for those A-ROWS figures but the NL operation executes only once (but accesses inner rowsource 100 times in case one and once in second case) in both cases (which is as expected).
    A closer test case (to OP) is
    SQL> select * from v$version ;
    BANNER                                                                                                                                                                    
    Oracle Database 10g Release 10.2.0.5.0 - Production                                                                                                                       
    PL/SQL Release 10.2.0.5.0 - Production                                                                                                                                    
    CORE     10.2.0.5.0     Production                                                                                                                                                
    TNS for Linux: Version 10.2.0.5.0 - Production                                                                                                                            
    NLSRTL Version 10.2.0.5.0 - Production                                                                                                                                    
    SQL> create table p nologging as select level as id, cast(dbms_random.string('a', 100) as varchar2(100)) as filler from dual connect by level <= 2000 ;
    Table created.
    SQL> exec dbms_stats.gather_table_stats(user, 'P') ;
    PL/SQL procedure successfully completed.
    SQL> create index p_id on p(id) nologging ;
    Index created.
    SQL> select count(*)  from p;
      COUNT(*)                                                                                                                                                                
          2000                                                                                                                                                                
    SQL> select count(*) , id from p group by id having count(*) > 1;
    no rows selected
    SQL> create table c nologging as select level as id, cast(dbms_random.string('a', 100) as varchar2(100)) as filler from dual connect by level <= 900 union all select 10, cast(dbms_random.string('a', 100) as varchar2(100)) as filler from dual connect by level <= 99 ;
    Table created.
    SQL> select count(*) , id from c group by id having count(*) > 1;
      COUNT(*)         ID                                                                                                                                                     
           100         10                                                                                                                                                     
    SQL> exec dbms_stats.gather_table_stats(user, 'C') ;
    PL/SQL procedure successfully completed.
    SQL> create index c_id on c(id) nologging ;
    Index created.
    SQL> select /*+ use_nl(p) leading(c) gather_plan_statistics */ * from p , c where p.id = c.id and c.id in (10) ;
            ID FILLER                                                                                                       ID                                                
    FILLER                                                                                                                                                                    
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    zrGZSmUFXNyNMOViUYSvPDdfznSlMvaFnQakopPtcBvXQkWmMlWCnrPyeZLfhuLLeYyAEkcwZNSfoASLYpoAnpESqlQWkaEGatXV                                                                      
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    hKtrWPCfAmWWLGMXfwHCusSwVpehEnZdxYPLouIuBlMMiSKlIJWwklZCAXZaCbIxKlhzBVRhhTPdLcheyAdoYyfxwomqWRrMXuMk                                                                      
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    ncSqclZvOGgyXDPaaouGaUqXmJtFNbNyFzUalDknEMvTsBRwGmTxOCIalLvqMnuTFBZJGzNfBqaSVHUtvNDceVZqKQQyqeGKOUdz                                                                      
    100 rows selected.
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST')) ;
    PLAN_TABLE_OUTPUT                                                                                                                                                         
    SQL_ID  1f55m4rabtu3h, child number 0                                                                                                                                     
    select /*+ use_nl(p) leading(c) gather_plan_statistics */ * from p , c where p.id = c.id and                                                                              
    c.id in (10)                                                                                                                                                              
    Plan hash value: 2553281496                                                                                                                                               
    | Id  | Operation                     | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |                                                                 
    |   0 | SELECT STATEMENT              |      |      0 |        |      0 |00:00:00.01 |       0 |      0 |                                                                 
    |   1 |  TABLE ACCESS BY INDEX ROWID  | P    |      1 |      1 |    100 |00:00:00.01 |     112 |      2 |                                                                 
    |   2 |   NESTED LOOPS                |      |      1 |      1 |    201 |00:00:00.02 |     110 |      2 |                                                                 
    |   3 |    TABLE ACCESS BY INDEX ROWID| C    |      1 |      1 |    100 |00:00:00.01 |       7 |      1 |                                                                 
    |*  4 |     INDEX RANGE SCAN          | C_ID |      1 |      1 |    100 |00:00:00.01 |       3 |      1 |                                                                 
    |*  5 |    INDEX RANGE SCAN           | P_ID |    100 |      1 |    100 |00:00:00.01 |     103 |      1 |                                                                 
    Predicate Information (identified by operation id):                                                                                                                       
       4 - access("C"."ID"=10)                                                                                                                                                
       5 - access("P"."ID"=10)                                                                                                                                                
    24 rows selected.
    SQL> select /*+ use_nl(c) leading(p) gather_plan_statistics */ * from p , c where p.id = c.id and c.id in (10) ;
            ID FILLER                                                                                                       ID                                                
    FILLER                                                                                                                                                                    
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    zrGZSmUFXNyNMOViUYSvPDdfznSlMvaFnQakopPtcBvXQkWmMlWCnrPyeZLfhuLLeYyAEkcwZNSfoASLYpoAnpESqlQWkaEGatXV                                                                      
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    hKtrWPCfAmWWLGMXfwHCusSwVpehEnZdxYPLouIuBlMMiSKlIJWwklZCAXZaCbIxKlhzBVRhhTPdLcheyAdoYyfxwomqWRrMXuMk                                                                      
            10 opKRJynLxjeCiOScvOklQBXfpnfgvlhHNLzlKKrFaNzQLODKSnKMxpzecqyFkVSLvdosZJhWckBcQbpIaqttahlqBxrugKQVrnIk         10                                                
    ncSqclZvOGgyXDPaaouGaUqXmJtFNbNyFzUalDknEMvTsBRwGmTxOCIalLvqMnuTFBZJGzNfBqaSVHUtvNDceVZqKQQyqeGKOUdz                                                                      
    100 rows selected.
    SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST')) ;
    PLAN_TABLE_OUTPUT                                                                                                                                                         
    SQL_ID  7hvf1zvsvfhdp, child number 0                                                                                                                                     
    select /*+ use_nl(c) leading(p) gather_plan_statistics */ * from p , c where p.id =                                                                                       
    c.id and c.id in (10)                                                                                                                                                     
    Plan hash value: 2133717140                                                                                                                                               
    | Id  | Operation                     | Name | Starts | E-Rows | A-Rows |   A-Time   | Buffers |                                                                          
    |   0 | SELECT STATEMENT              |      |      0 |        |      0 |00:00:00.01 |       0 |                                                                          
    |   1 |  TABLE ACCESS BY INDEX ROWID  | C    |      1 |      1 |    100 |00:00:00.01 |      11 |                                                                          
    |   2 |   NESTED LOOPS                |      |      1 |      1 |    102 |00:00:00.01 |       7 |                                                                          
    |   3 |    TABLE ACCESS BY INDEX ROWID| P    |      1 |      1 |      1 |00:00:00.01 |       4 |                                                                          
    |*  4 |     INDEX RANGE SCAN          | P_ID |      1 |      1 |      1 |00:00:00.01 |       3 |                                                                          
    |*  5 |    INDEX RANGE SCAN           | C_ID |      1 |      1 |    100 |00:00:00.01 |       3 |                                                                          
    Predicate Information (identified by operation id):                                                                                                                       
       4 - access("P"."ID"=10)                                                                                                                                                
       5 - access("C"."ID"=10)                                                                                                                                                
    24 rows selected.
    SQL> drop table p purge ;
    Table dropped.
    SQL> drop table c purge ;
    Table dropped.
    SQL> spool offEdited by: user503699 on Jan 18, 2012 11:49 PM

  • Serialization custom Class Object

    Hi,
    I'm kind of stuck with a problem.
    I've been writing a servlet and applet that are communicating over
    internet using a socket connection and Object Serialization.
    The objects that are passed are custom:
    public class mcuComObj implements Serializable{
        static final long  serialVersionUID = 2222;
        private String name;
        private Vector attributes;
        ...There are some more functions but those are not of any interest.
    In the vector attributes, I've planted a jPanel (swing).
    The weird thing is that this morning, it worked a few times...after that
    I'm getting the:
    javax.swing.JComponent; local class incompatible: stream classdesc serialVersionUID = 6954663636822719621, local class serialVersionUID = 5896976265092562486 ERROR message.
    The send code:
    Vector v = new Vector();
    Object objButton = (Object) jButton1;
    v.add(objButton);
    obj.setAttributes(v);  //obj = mcuComObj
    con.sendObject(obj);   //con = socket connection threadThe receive code:
    Object input= (Object) objInpStr.readObject();When I serialize the mcuComObj class, does it also serialize the
    embedded objects (in this case that are in the Vector)?
    The main question is...how can I solve this? I can not guarantee that
    both Servlet and Applet have the same JDK running...!
    Have anyone of you got any ideas?
    Thanks in advance,
    Chris van Diemen

    If the "magic numbers" (sent at the beginning of any writeObject() call) on the sending and receiving JDK differ, the object will not de-serialize properly on the receiving end.
    The easist solution would be to use a common format to transmit the data. Say! That sounds like XML.
    - Saish
    "My karma ran over your dogma." - Anon

  • Unable to create Instance with Object Editor and Attachment Pattern

    Hi Experts,
    I created a simple entity service with some attributes and a document reference.
    I also configured an object editor pattern and assigned a attachment pattern. The created object editor works as long as I don't attach a file. But if I attach a file and want to save it I get an error message "cannot create"
    In the default log.trc I have some entries
    Cannot read associated instance with MOF ID 105D8E0C4F02D45AFFD5B9D6A09EFB7A of MOF Layer 2 for (6DC24B80F6004CDBF4FA6C560AEDD33C,<null>)
    and
    refPackageM1(com.sap.ip.bi.sdk.dac.olap.query) failed RepositoryDBMemory. Using generic one.
    I configured the j2ee engine according the tutorial "Integrating KM with CAF UI Patterns"
    So what is wrong?
    Best regards Manuel

    Hi,
    From the stacktrace I assume that the following happens (please correct me, if I'm wrong):
    <b>*</b> Some time based event mechanism sends an event to your custom event handler code. That code is execute in some system context.
    <b>*</b> Your handler uses the RF API to create a collection. All this is perfectly OK. Here my assumptions end, the next steps are solid facts.
    <b>*</b> Within the RF all property filters are informed that a resource is about to be created. One of the filters is trying to obtain a lock from a system provided Locking Service.
    <b>*</b> That service refuses to grant the lock, telling that system users are not allowed to do so.
    Most proably you cannot do anything to solve this problem by yourself. When I ran into the same Exception once, I could avoid to have my code run in a system thread. Well you might try to do the same.
    Otherwise please open a customer message and complain about the restiction in the locking behaviour.
    Best regards,
    Michael

  • COPA Report Layout with Object List (ALV)

    Hi,
    I have question about the COPA report layout with object list (ALV). Everytime I executed the report with ALV format, the amount for quantity column always shows with 3 decimal number, menwhile for amount column always follow by 2 decimal number.
    Can anyone help me regarding this matter? I do not know how to turn off the decimal number to be 0 in this type of layout, although in the form itself I already put 0 decimal number.
    Thanks.

    Hi,
    Better to raise this issue in CO Forum. You can expect some solution.
    regards

  • Can't figure out why colors don't totally change when you select type with curser? It looks like it has by looking at it, but when you highlight the area after the old color is still there. It happens with objects to. Driving me NUTZ. Help!

    Can't figure out why colors don't totally change when you select type with curser? It looks like it has by looking at it, but when you highlight the area after the old color is still there. It happens with objects to. Driving me NUTZ. Help!

    Select the text, and open the Appearance palette (Come on guys, text highlight is irrelevant, it happens to objects too says the OP), and see what's listed there.  For a simple text object, there should only be a line item "Type", followed by "Characters", and when double-clicked the Characters line item expands to tell you the stroke and fill color.  For a basic object, there should be a fill and/or stroke.
    What happens sometimes, is that you end up adding extra strokes/fills to objects or text, and the appearance palette is where that will be noted.  Especially when you are dealing with groups, and/or picking up a color with the eyedropper, you may inadvertently be adding a fill or stroke on top of something.  You can drag those unwanted thingies from the Appearance palette into its own little trash can.

  • Mapping refcursors with object types in a procedure

    Hi all,
    I need some help regarding the mapping of refcursors with object types .
    Example: Procedure "A" has object types as input/output parameters which lies in the Web Method Application as a API.
    We are creating a procedure "B" which has ref cursors as input/ouput parameters
    which will map to the Procedure "A"'s object type parameters.
    It will be highly needful for the solution.
    Regards
    Saugata

    Your pseudocode has a lot of steps in it, but you didn't say which step you need help with. Since I already covered going from a nested table type to a refcursor, I'll assume you want an example that goes the other way now, like from a refcursor to a nested table type. Here's one ...
    SQL>
    SQL>
    SQL> set serveroutput on
    SQL>
    SQL> create type nested_table_type as table of varchar2(14) ;
      2  /
    Type created.
    SQL> show errors
    No errors.
    SQL>
    SQL>
    SQL> create function func
      2    ( p_cursor in sys_refcursor )
      3    return nested_table_type
      4  as
      5    v_nested_table nested_table_type ;
      6  begin
      7
      8    fetch p_cursor bulk collect into v_nested_table ;
      9    return( v_nested_table );
    10
    11  end;
    12  /
    Function created.
    SQL> show errors
    No errors.
    SQL>
    SQL> select func( cursor( select dname from dept ) ) as nested_table from dual ;
    NESTED_TABLE
    NESTED_TABLE_TYPE('ACCOUNTING', 'RESEARCH', 'SALES', 'OPERATIONS')If your cursor selects objects instead of simple data types, the code is pretty much the same.
    SQL> create type object_type as object ( c1 varchar2(14), c2 varchar2(13) );
      2  /
    Type created.
    SQL> show errors
    No errors.
    SQL>
    SQL> create type nested_table_type as table of object_type ;
      2  /
    Type created.
    SQL> show errors
    No errors.
    SQL>
    SQL>
    SQL>
    SQL> create function func
      2    ( p_cursor in sys_refcursor )
      3    return nested_table_type
      4  as
      5    v_nested_table nested_table_type ;
      6  begin
      7
      8    fetch p_cursor bulk collect into v_nested_table ;
      9    return( v_nested_table );
    10
    11  end;
    12  /
    Function created.
    SQL> show errors
    No errors.
    SQL>
    SQL> select
      2    func( cursor( select object_type( dname, loc ) from dept ) ) as object_table
      3  from dual ;
    OBJECT_TABLE(C1, C2)
    NESTED_TABLE_TYPE
      ( OBJECT_TYPE('ACCOUNTING', 'NEW YORK'),
        OBJECT_TYPE('RESEARCH', 'DALLAS'),
        OBJECT_TYPE('SALES', 'CHICAGO'),
        OBJECT_TYPE('OPERATIONS', 'BOSTON')
      )(NB I manually reformated the query results for clarity).

Maybe you are looking for