0 Replies Latest reply on Oct 29, 2002 10:24 AM by tejasab

    JBoss stores java.lang.String incorrectly ??

    tejasab

      Hi,
      My code is giving strange results on Jboss. The code is in an OJB and runs on JBoss.

      Some of the relevant code fragment is as under :

      arr = (ARRAY)rset.getArray(1);
      Object [] obj = (Object []) arr.getArray();

      String strColName = null;
      String strTableName = null;
      String strColVal = null;

      Logger.write("SQL Query fetched records, starting to process records" , true);

      for(int q = 0; q < obj.length; q++ )
      {
      HashMap hashMap = new HashMap();

      STRUCT strc = (STRUCT) obj[q];
      Object [] obj1 = (Object []) strc.getAttributes();
      //Add instance data to the HashMap
      for (int colCount=0; colCount < columnNames.length ; colCount++)
      {
      strColName = (String) columnNames[colCount];
      if(obj1[colCount] != null && obj1[colCount] instanceof java.lang.String )
      {
      strColVal = (String) obj1[colCount];
      System.out.println("The column value is " + strColVal);
      hashMap.put(strColName ,
      new Attribute(strColVal.toString() ,"") );
      }
      else
      {
      hashMap.put(strColName ,
      new Attribute(obj1[colCount],"") );
      }


      The above code is not complete, but gives only the relevant section that is experiencing problems.
      The above code does a very simple task, fetches data from the database, and puts the each of the data row in the hashmap. Oracle ARRAY mechanism is used to fetch the data.

      Please take a look at the System.out code line. It is inside if block. Now, the strange thing is that when the System.out line is executed by JBoss, the column value is printed as "0x53544D2D31204C2D312E31206F74"

      How is this possible ? Is something wrong in my code ??
      The fact that System.out code is executed, means that the data is of java.lang.String, why does Jboss print the hex representation of the string ????

      Now, when I run the same code on OC4J, the results are as expected, OC4J prints the string as expected.

      Has anyone faced this problem before ??? Can someone give some help ?
      I would really like my project to use JBoss, but if this cannot be solved, I guess I'll have to move on to OC4J as time scales are very thin.

      Can someone please help....

      Thanks,
      Tejas