Loading ...
Sorry, an error occurred while loading the content.

Re: [xml-dbms] JDBC2DataSource, retrieve document using ResultSet,java.lang.VerifyError

Expand Messages
  • Ronald Bourret
    ... You re weelcome. ... I m afraid I can t answer this one. Adam Flinton wrote the code for 1.1 and I just stole it. I don t have JNDI on my machine, so I
    Message 1 of 5 , Apr 9, 2002
    • 0 Attachment
      aditya_s_a wrote:
      >
      > Thanks for your recent answers Ron.

      You're weelcome.

      > Btw, i still cannot use JDBC2DataSource. it seems i passs the wrong
      > jndiContext.
      > Could you give a simple example on how to construct JDBC2DataSource
      > object and
      > simple code on how to use it.

      I'm afraid I can't answer this one. Adam Flinton wrote the code for 1.1
      and I just stole it. I don't have JNDI on my machine, so I can't test
      it. (Yes, XML-DBMS does have some frightening little secrets...)

      Adam?

      > Oh, could you also give simple example on how to write xml document
      > from
      > ResultSet that manually acquired using PreparedStatement,not using
      > filter. i've tried it,but xmldbms gave me error message stating that
      > i have incompatible StringFormatter. (I traced the source code, and
      > found that for String type column is being handled by DateFormatter.)

      This sounds like a bug. Can you post your code, map, filter, etc.?
      Thanks.

      > There's another question.
      > I have error message:
      > java.lang.VerifyError: (class:
      > org/xmlmiddleware/domutils/helpers/ParserUtilsXerces, method:
      > openDocument signature: (Lorg/xml/sax/InputSource;)
      > Lorg/w3c/dom/Document;) Incompatible object argument for method call
      >
      > when calling this statement:
      > ParserUtils utils = (ParserUtils)new
      > org.xmlmiddleware.domutils.helpers.ParserUtilsXerces();
      >
      > This didn't happen if i include the ParserUtilsXerces source code in
      > my code instead of using the xmldbms20.jar.
      > And now, i'm using newly jar-ed xmldbms20.jar with newly compiled
      > ParserUtilsXerces class replacing the old one.
      > I'm pretty sure that the new compiled ParserUtilsXerces class is
      > different with old one. they have different filesize.
      >
      > Am i misconfigure my project/system/classpath?

      The signature of ParserUtils.openDocument changed between alpha 1 and
      alpha 2, so make sure you're not mixing those. (I also just noticed that
      I forgot to list this in the change doc. Sorry.)

      -- Ron
    • aditya_s_a
      Here s the map file:
      Message 2 of 5 , Apr 9, 2002
      • 0 Attachment
        Here's the map file:

        <?xml version='1.0' ?>
        <!DOCTYPE XMLToDBMS SYSTEM "xmldbms2.dtd" >

        <XMLToDBMS Version="2.0" xmlns="http://www.xmlmiddleware.org/xmldbms/v2">
        <Options>
        <SimpleDateFormat Pattern="MMddyyyy:hhmmss" DefaultForTypes="TIMESTAMP" />
        </Options>
        <Databases>
        <Database Name="Default">
        <Catalog>
        <Schema>
        <Table Name="SESSIONS">
        <Column Name="session_id" DataType="VARCHAR" Length="20" Nullable="No"/>
        <Column Name="sysid" DataType="VARCHAR" Length="20" Nullable="Yes"/>
        <Column Name="xml_string" DataType="VARCHAR" Length="255" Nullable="Yes"/>
        <Column Name="stime" DataType="TIMESTAMP" Nullable="Yes"/>
        <Column Name="etime" DataType="TIMESTAMP" Nullable="Yes"/>
        <PrimaryKey>
        <UseColumn Name="session_id"/>
        </PrimaryKey>
        </Table>

        <Table Name="CALLS">
        <Column Name="session_id" DataType="VARCHAR" Length="20" Nullable="No"/>
        <Column Name="call_id" DataType="VARCHAR" Length="20" Nullable="No"/>
        <Column Name="type" DataType="VARCHAR" Length="20" Nullable="No"/>
        <Column Name="status" DataType="VARCHAR" Length="20" Nullable="Yes"/>
        <Column Name="port" DataType="BIGINT" Nullable="Yes"/>
        <Column Name="cli" DataType="VARCHAR" Length="50" Nullable="Yes"/>
        <Column Name="did" DataType="VARCHAR" Length="50" Nullable="Yes"/>
        <Column Name="charge" DataType="VARCHAR" Length="50" Nullable="Yes"/>
        <Column Name="stime" DataType="TIMESTAMP" Nullable="Yes"/>
        <Column Name="etime" DataType="TIMESTAMP" Nullable="Yes"/>
        <PrimaryKey>
        <UseColumn Name="call_id"/>
        </PrimaryKey>
        <ForeignKey Name="CALL_TO_SESSION_FK">
        <UseTable Name="SESSIONS" />
        <UseUniqueKey Name="PrimaryKey" />
        <UseColumn Name="session_id"/>
        </ForeignKey>
        </Table>

        <Table Name="CONTENTACCESSEVENTS">
        <Column Name="session_id" DataType="VARCHAR" Length="20" Nullable="No"/>
        <Column Name="call_id" DataType="VARCHAR" Length="20" Nullable="No"/>
        <Column Name="event_id" DataType="VARCHAR" Length="20" Nullable="No"/>
        <Column Name="charge" DataType="VARCHAR" Length="50" Nullable="Yes"/>
        <Column Name="stime" DataType="TIMESTAMP" Nullable="Yes"/>
        <Column Name="etime" DataType="TIMESTAMP" Nullable="Yes"/>
        <PrimaryKey>
        <UseColumn Name="event_id"/>
        </PrimaryKey>
        <ForeignKey Name="EVENT_TO_SESSION_FK">
        <UseTable Name="SESSIONS" />
        <UseUniqueKey Name="PrimaryKey" />
        <UseColumn Name="session_id"/>
        </ForeignKey>
        <ForeignKey Name="EVENT_TO_CALL_FK">
        <UseTable Name="CALLS" />
        <UseUniqueKey Name="PrimaryKey" />
        <UseColumn Name="call_id"/>
        </ForeignKey>
        </Table>
        </Schema>
        </Catalog>
        </Database>
        </Databases>
        <Maps>
        <ClassMap>
        <ElementType Name="session" />
        <ToClassTable Name="SESSIONS"/>
        <PropertyMap>
        <Attribute Name="id"/>
        <ToColumn Name="session_id"/>
        </PropertyMap>
        <PropertyMap>
        <ElementType Name="sysid"/>
        <ToColumn Name="sysid"/>
        </PropertyMap>
        <PropertyMap>
        <ElementType Name="xml_string"/>
        <ToColumn Name="xml_string"/>
        </PropertyMap>
        <PropertyMap>
        <ElementType Name="stime"/>
        <ToColumn Name="stime"/>
        </PropertyMap>
        <PropertyMap>
        <ElementType Name="etime"/>
        <ToColumn Name="etime"/>
        </PropertyMap>
        <RelatedClass KeyInParentTable="Unique">
        <ElementType Name="call"/>
        <UseUniqueKey Name="PrimaryKey"/>
        <UseForeignKey Name="CALL_TO_SESSION_FK"/>
        </RelatedClass>
        </ClassMap>

        <ClassMap>
        <ElementType Name="call"/>
        <ToClassTable Name="CALLS"/>
        <PropertyMap>
        <Attribute Name="session_id"/>
        <ToColumn Name="session_id"/>
        </PropertyMap>
        <PropertyMap>
        <Attribute Name="id"/>
        <ToColumn Name="call_id"/>
        </PropertyMap>
        <PropertyMap>
        <Attribute Name="type"/>
        <ToColumn Name="type"/>
        </PropertyMap>
        <PropertyMap>
        <ElementType Name="status"/>
        <ToColumn Name="status"/>
        </PropertyMap>
        <PropertyMap>
        <ElementType Name="stime"/>
        <ToColumn Name="stime"/>
        </PropertyMap>
        <PropertyMap>
        <ElementType Name="etime"/>
        <ToColumn Name="etime"/>
        </PropertyMap>
        <PropertyMap>
        <ElementType Name="cli"/>
        <ToColumn Name="cli"/>
        </PropertyMap>
        <PropertyMap>
        <ElementType Name="did"/>
        <ToColumn Name="did"/>
        </PropertyMap>
        <PropertyMap>
        <ElementType Name="port"/>
        <ToColumn Name="port"/>
        </PropertyMap>
        <PropertyMap>
        <ElementType Name="charge"/>
        <ToColumn Name="charge"/>
        </PropertyMap>
        <InlineMap>
        <ElementType Name="events" />
        <RelatedClass KeyInParentTable="Unique">
        <ElementType Name="contentaccess"/>
        <UseUniqueKey Name="PrimaryKey"/>
        <UseForeignKey Name="EVENT_TO_CALL_FK"/>
        </RelatedClass>
        </InlineMap>
        </ClassMap>
        <ClassMap>
        <ElementType Name="contentaccess"/>
        <ToClassTable Name="CONTENTACCESSEVENTS"/>
        <PropertyMap>
        <Attribute Name="session_id"/>
        <ToColumn Name="session_id"/>
        </PropertyMap>
        <PropertyMap>
        <Attribute Name="call_id"/>
        <ToColumn Name="call_id"/>
        </PropertyMap>
        <PropertyMap>
        <Attribute Name="id"/>
        <ToColumn Name="event_id"/>
        </PropertyMap>
        <PropertyMap>
        <ElementType Name="stime"/>
        <ToColumn Name="stime"/>
        </PropertyMap>
        <PropertyMap>
        <ElementType Name="etime"/>
        <ToColumn Name="etime"/>
        </PropertyMap>
        <PropertyMap>
        <ElementType Name="charge"/>
        <ToColumn Name="charge"/>
        </PropertyMap>
        </ClassMap>
        </Maps>
        </XMLToDBMS>

        While for the filter,i'm not using .ftr file.instead i manually construct it.
        (May be this which cause the problem..:) ).

        Here's my code:

        private void transferToXML(String sessionId, java.sql.Timestamp fromDate, java.sql.Timestamp toDate) {
        String transformedCdr = null;
        try {
        ResultSet rs = retrieveFilteredResultSet(dataSource, sessionId, fromDate, toDate);
        FilterSet filterSet = new FilterSet(map);
        ResultSetFilter rsFilter = filterSet.createResultSetFilter("Default");
        rsFilter.setTable("Default", null, null, "SESSIONS");

        ParserUtils utils = (ParserUtils) new org.xmlmiddleware.domutils.helpers.ParserUtilsXerces();
        DBMSToDOM dbmsToDOM = new DBMSToDOM(utils);
        dbmsToDOM.setDTDInfo(null, null);

        Document doc = dbmsToDOM.retrieveDocument(transferInfo, rs,filterSet, null, null);
        String cdrResult = utils.writeDocument(doc);
        } catch (Exception e) {
        }
        }


        QUESTIONS:
        Q.A. My Above Code:
        1. I guess the above code only retrieve a single parent table w/o its
        cild/related tables. If i only specify the root table and get
        its child,what should i do?

        Q.A. Filter Language & file:
        1. if i use:
        <RootFilter>
        <Table Name="sessions"/>
        <Where Condition="id='SessionID1'"/>
        </RootFilter>
        will it also retrieve the related/child tables?
        2. how to pass Condition value that is not in String type, such as Date type?

        Q.B. Map Language & file:
        1. What is the difference between:
        <RelatedClass KeyInParentTable="Foreign"> and
        <RelatedClass KeyInParentTable="Unique">.
        In what situation i must use each of them?
        Can i use them simultenously?

        2. will Format Attribute in Column tag enforce the StringFormatter type used?
        if it does,will it solve previous problem?
        What are valid values for Format Attribute?

        3. Is it safe to have single compiled map for all client instances?
        (i noticed that it takes some times to read and compile map file.)
      • Ronald Bourret
        I m still trying to find out why XML-DBMS is using the wrong StringFormatter. Here are the answers to your other questions. -- Ron ... Your code to build a
        Message 3 of 5 , Apr 11, 2002
        • 0 Attachment
          I'm still trying to find out why XML-DBMS is using the wrong
          StringFormatter. Here are the answers to your other questions.

          -- Ron

          aditya_s_a wrote:

          > While for the filter,i'm not using .ftr file.instead i manually
          > construct it. (May be this which cause the problem..:) ).

          Your code to build a filter looks OK, but you should be careful when you
          do this. The objects in the filters package will catch most (but
          probably not all) errors when constructing FilterSet objects. However,
          they do not check if you have constructed complete objects. For example,
          it is possible to construct a FilterSet object that has no root filters
          or result set filters.

          (I can't remember exactly what constitutes a "complete" FilterSet
          object. However, the rules are expressed in the filters DTD. That is, if
          you look at the DTD, you should be able to figure out what a complete /
          legal object is.)

          The same warning holds true for constructing your own Actions object.

          > QUESTIONS:
          > Q.A. My Above Code:
          > 1. I guess the above code only retrieve a single parent table w/o its
          > cild/related tables. If i only specify the root table and get
          > its child,what should i do?

          Whether XML-DBMS retrieves child/related tables depends on the map you
          are using, not the filters. You can think of it this way. The map
          defines a hierarchy of tables in the database while the filters define
          exactly which rows in those tables to retrieve.

          When you pass a result set to retrieveDocument, you are defining what
          rows in the root table you are interested in. If your map defines child
          tables, DBMSToDOM retrieves data from the child tables based on the
          values in the result set.

          > Q.A. Filter Language & file:
          > 1. if i use:
          > <RootFilter>
          > <Table Name="sessions"/>
          > <Where Condition="id='SessionID1'"/>
          > </RootFilter>
          > will it also retrieve the related/child tables?

          As I said above, it will do this if the map includes related/child
          tables. (Yours does.)

          > 2. how to pass Condition value that is not in String type, such as Date type?

          You pass it the same way you would pass it when typing an SQL string in
          at a terminal -- note that this may be database dependent, especially
          for dates. XML-DBMS just appends the condition values to the SELECT
          statements it constructs. For example, if your database supports SQL 99
          syntax and you want all etime values greater than April 2, 2002 at
          9:00am, you would use the condition:

          etime > '2002-04-02 09:00:00'

          > Q.B. Map Language & file:
          > 1. What is the difference between:
          > <RelatedClass KeyInParentTable="Foreign"> and
          > <RelatedClass KeyInParentTable="Unique">.
          > In what situation i must use each of them?

          These tell XML-DBMS whether the parent or child table has the
          primary/unique key that joins the tables. This is important for
          maintaining referential integrity when inserting or deleting data. It is
          not important when retrieving data.

          For example, in the sales order example shipped with XML-DBMS, in the
          relation between the Orders and Items tables, the unique key is in the
          parent (Orders). In the relation between the Orders and Customers
          tables, the unique key is in the child (Customers).

          Which one you use depends on the structure of your database. In a
          normalized database, the unique key will be on the "one" side of a
          one-to-many relationship.

          > Can i use them simultenously?

          You can use them in the same map file. You cannot use both on the same
          RelatedClass element.

          >
          > 2. will Format Attribute in Column tag enforce the StringFormatter type used?

          Yes. The Format attribute gives the logical name of the StringFormatter
          class to use. (Logical names are defined in DateFormat, TimeFormat,
          DecimalFormat, FormatClass, etc. elements.) For details, see the subject
          "Associating formats with columns" in the xmldbms2 DTD. For examples,
          see format.map in samples/maps/v2.0 in the CVS tree.

          > if it does,will it solve previous problem?

          Maybe, but I doubt it.

          > What are valid values for Format Attribute?

          A logical format name defined by one of the format definition elements
          in the map file.

          > 3. Is it safe to have single compiled map for all client instances?
          > (i noticed that it takes some times to read and compile map file.)

          Yes (mostly). It is always safe if you compile the map, then use it in
          multiple calls in single-threaded code. I believe it's safe if you use
          it in multi-threaded code *after* the map has been compiled, but I am
          not 100% sure. Note that TransferInfo objects are never thread safe.
        • Ronald Bourret
          ... The problem is that you have not told XML-DBMS what order the columns occur in the result set. Without knowing this, it doesn t know which column mapping
          Message 4 of 5 , Apr 12, 2002
          • 0 Attachment
            > aditya_s_a wrote:
            > > Oh, could you also give simple example on how to write xml document
            > > from
            > > ResultSet that manually acquired using PreparedStatement,not using
            > > filter. i've tried it,but xmldbms gave me error message stating that
            > > i have incompatible StringFormatter. (I traced the source code, and
            > > found that for String type column is being handled by DateFormatter.)

            The problem is that you have not told XML-DBMS what order the columns
            occur in the result set. Without knowing this, it doesn't know which
            column mapping information to apply to which result set column. It is
            therefore guessing incorrectly.

            There are two ways to do this:

            1) Use maps.utils.MetadataInitializer to get figure out column order
            from the result set. Your code needs to know which table the result set
            applies to.

            MetadataInitializer mi = new MetadataInitializer(map);
            mi.initializeMetadata(null, null, null, "MyTableName", rs);

            2) Get the Table, get each Column, and set the column result set index.
            Your code needs to know the table the result set applies to and the
            order that columns occur in the result set. For example:

            String myTableName = "MyTable";
            // column names in result set order
            String[] myColumnNames = {"column1", "column2", "column3"};

            Table myTable = map.getClassTable(null, null, null, myTableName);
            for (int i = 0; i < myColumnNames.length; i++)
            {
            Column column = myTable.getColumn(myColumnNames[i]);
            column.setResultSetIndex(i + 1); // indexes are 1-based
            }

            NOTES:

            a) This is not obvious -- even Transfer got it wrong.

            b) I will probably add this result set indices to the mapping language.

            c) I thought about having DBMSToDOM do (1) automatically. However, this
            is expensive if you retrieve data from multiple result sets with the
            same metadata. I will see if there is an easier way to do this...

            -- Ron
          Your message has been successfully submitted and would be delivered to recipients shortly.