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

Re: [xml-dbms] statement closed

Expand Messages
  • Ying Jin
    Dear Ronald, Thanks for your reply. I have made the changes you suggested in the following message and I m still getting the same error. 1. I have changed the
    Message 1 of 6 , Nov 28, 2005
    • 0 Attachment
      Dear Ronald,

      Thanks for your reply. I have made the changes you
      suggested in the following message and I'm still
      getting the same error.

      1. I have changed the Description column to nullable.
      2. Change the DTD file as you suggested.
      3. Change the XML file as you suggested.

      I think this time the XML file matches the DTD file.
      Here is the SQL statement I used to create the
      Collections table.

      CREATE TABLE Collections (
      Collection_id INT UNSIGNED NOT NULL,
      Collection_name VARCHAR(50) NOT NULL,
      Description VARCHAR(500),
      CONSTRAINT PrimaryKey PRIMARY KEY (`Collection_id`)
      );

      I deleted all records in this table too.

      Any clue?

      Thanks very much,
      Ying

      --- Ronald Bourret <rpbourret@...> wrote:

      > Hello,
      >
      > The problem is probably that your XML document does
      > not match your DTD.
      > In particular, the DTD allows only a single
      > collection ID, collection
      > name, and description in a Collections element. Your
      > XML document
      > includes information about multiple collections in a
      > single Collections
      > element.
      >
      > (The element name "Collections" is misleading, since
      > it implies that
      > there can be multiple collections in a Collections
      > element. This
      > illustrates the problems in automatically generating
      > schemas -- the
      > element name is taken from the table name, which is
      > plural, but only
      > describes a single row of data, which is singular.)
      >
      > You have two other problems with your XML document,
      > neither of which is
      > likely to be causing this problem:
      >
      > 1) You don't always include a Description element in
      > your XML document,
      > but the DTD (and the database) requires this
      > element. This shouldn't
      > cause the problem you are seeing, but will cause an
      > insert error, since
      > the Description column in your database is
      > non-nullable.
      >
      > 2) The order of elements in your document doesn't
      > match the order
      > specified by the DTD. In particular, the children
      > must be in the order
      > Description, Collection_id, Collection_name, but
      > your XML document has
      > them in the order Collection_id, Collection_name,
      > Description. I don't
      > believe this will cause any problems for XML-DBMS,
      > but this will cause
      > problems if you try to validate your XML document
      > against the generated DTD.
      >
      >
      > To fix this problem:
      >
      > 1) Change your DTD to add a Collection element,
      > place child elements in
      > the order you want them, and make the Description
      > element optional:
      >
      > <!ELEMENT Collections (Collection+)>
      > <!ELEMENT Collection (Collection_id,
      > Collection_name, Description?)>
      > <!ELEMENT Description (#PCDATA)>
      > <!ELEMENT Collection_name (#PCDATA)>
      > <!ELEMENT Collection_id (#PCDATA)>
      >
      > 2) Change your database so that the Description
      > column is non-nullable.
      >
      > 3) In your map document, change the ElementType
      > element in the ClassMap
      > to map the Collection element, not the Collections
      > element:
      >
      > <ElementType Name="Collection"/>
      >
      > 4) Change your XML document to use the Collection
      > element:
      >
      > <Collections>
      > <Collection>
      > <Collection_id>1</Collection_id>
      > <Collection_name>Nepal</Collection_name>
      > <Description>This is a test</Description>
      > </Collection>
      > <Collection>
      > <Collection_id>2</Collection_id>
      > <Collection_name>IASCP</Collection_name>
      > <Description>Test IASCP</Description>
      > </Collection>
      > <Collection>
      > <Collection_id>3</Collection_id>
      > <Collection_name>Italy6-1978</Collection_name>
      > <Description>Something</Description>
      > </Collection>
      > <Collection>
      > <Collection_id>4</Collection_id>
      > <Collection_name>Workshop</Collection_name>
      > <Description>test</Description>
      > </Collection>
      > <Collection>
      > <Collection_id>6</Collection_id>
      > <Collection_name>ttest</Collection_name>
      > </Collection>
      > <Collection>
      > <Collection_id>7</Collection_id>
      > <Collection_name>YingTesting</Collection_name>
      > </Collection>
      > </Collections>
      >
      > -- Ron
      >
      > elsa_jin wrote:
      >
      > > Hi all,
      > >
      > > I just tried xmldbms days ago. What I'm trying to
      > do is transfering
      > > data from MS Access to MySQL database. I used
      > MapManager tool to
      > > generate a DTD file and a Map file from the
      > database. It worked.
      > > However, when I use transfer tool to transfer
      > data, I got:
      > > java.sql.SQLException:
      > [XML-DBMS][SPPreparedStatement] Statement closed.
      > > at
      > >
      >
      org.xmlmiddleware.db.SPPreparedStatement.checkState(SPPreparedStatement.java:833)
      > > at
      > >
      >
      org.xmlmiddleware.db.SPPreparedStatement.setAsciiStream(SPPreparedStatement.java:313)
      > > at
      > >
      >
      org.xmlmiddleware.xmldbms.datahandlers.Parameters.setParameter(Parameters.java:181)
      > > at
      > >
      >
      org.xmlmiddleware.xmldbms.datahandlers.Parameters.setParameters(Parameters.java:89)
      > > at
      > >
      >
      org.xmlmiddleware.xmldbms.datahandlers.DataHandlerBase.makeInsert(DataHandlerBase.java:378)
      > > at
      > >
      >
      org.xmlmiddleware.xmldbms.datahandlers.GenericHandler.insert(GenericHandler.java:49)
      > > at
      > >
      >
      org.xmlmiddleware.xmldbms.DOMToDBMS.storeRow(DOMToDBMS.java:1324)
      > > at
      > >
      >
      org.xmlmiddleware.xmldbms.DOMToDBMS.processClassRow(DOMToDBMS.java:552)
      > > at
      > >
      >
      org.xmlmiddleware.xmldbms.DOMToDBMS.processRoot(DOMToDBMS.java:447)
      > > at
      > >
      >
      org.xmlmiddleware.xmldbms.DOMToDBMS.storeDocument(DOMToDBMS.java:368)
      > > at
      > >
      >
      org.xmlmiddleware.xmldbms.DOMToDBMS.storeDocument(DOMToDBMS.java:317)
      > > at
      > >
      >
      org.xmlmiddleware.xmldbms.tools.Transfer.storeDocumentInternal(Transfer.java:840)
      > > at
      > >
      >
      org.xmlmiddleware.xmldbms.tools.Transfer.storeDocument(Transfer.java:479)
      > > at
      > >
      >
      org.xmlmiddleware.xmldbms.tools.Transfer.dispatchStoreDocument(Transfer.java:696)
      > > at
      > >
      >
      org.xmlmiddleware.xmldbms.tools.Transfer.dispatch(Transfer.java:434)
      > > at
      > >
      >
      org.xmlmiddleware.xmldbms.tools.Transfer.main(Transfer.java:353)
      > >
      > > ==============================
      > > Here is the details of my environment:
      > > ----------
      > > db.props
      > > ----------
      > > #Properties for XML-DBMS
      > > URL=jdbc:mysql://localhost:3306/DLCImage
      > > Driver=com.mysql.jdbc.Driver
      > >
      > DataSourceClass=org.xmlmiddleware.db.JDBC1DataSource
      > > DBName=DLCImage
      > > User=xxx
      > > Password=xxx
      > >
      > > ---------
      > > map.props
      > > ---------
      > > #Properties for MapManager
      > > Input=Database
      > > RootDatabase=DLCImage
      > > RootTable=Collections
      > > Output1=Map
      > > MapFile=Collections.map
      > > Output2=DTD
      > > DTDFile=Collections.dtd
      > >
      > > ------------
      > > parser.props
      > > ------------
      >
      === message truncated ===





      __________________________________
      Yahoo! Mail - PC Magazine Editors' Choice 2005
      http://mail.yahoo.com
    • Ronald Bourret
      Hello, I just realized I never answered this. Are you still having this problem? I tried to recreate the problem here and was not able to. I used the following
      Message 2 of 6 , Dec 15, 2005
      • 0 Attachment
        Hello,

        I just realized I never answered this. Are you still having this problem?

        I tried to recreate the problem here and was not able to. I used the
        following command:

        java org.xmlmiddleware.xmldbms.tools.Transfer File1=parser.props
        File2=db.props File3=transfer.props

        and the files listed below.

        I then looked through the code. This part of the code is pretty
        confusing, but I was not able to find a way for this error to occur. In
        particular, none of the code in DOMToDBMS ever closes the JDBC statement
        or connection, so I couldn't figure out what was happening.

        -- Ron

        collections.act
        ---------------
        <Actions Version="2.0"
        xmlns="http://www.xmlmiddleware.org/xmldbms/actions/v2">
        <DefaultAction>
        <Insert />
        </DefaultAction>
        </Actions>

        collections.map
        ---------------
        <!DOCTYPE XMLToDBMS >
        <XMLToDBMS Version="2.0" xmlns="http://www.xmlmiddleware.org/xmldbms/v2">
        <Databases>
        <Database Name="DLCImage">
        <Catalog>
        <Schema>
        <Table Name="Collections">
        <Column Name="Description" DataType="LONGVARCHAR" Length="65535"
        Nullable="Yes"/>
        <Column Name="Collection_name" DataType="VARCHAR" Length="50"
        Nullable="No"/>
        <Column Name="Collection_id" DataType="INTEGER" Nullable="No"/>
        <PrimaryKey>
        <UseColumn Name="Collection_id"/>
        </PrimaryKey>
        </Table>
        </Schema>
        </Catalog>
        </Database>
        </Databases>
        <Maps>
        <ClassMap>
        <ElementType Name="Collection"/>
        <ToClassTable Database="DLCImage" Name="Collections"/>
        <PropertyMap TokenList="No" ContainsXML="No">
        <ElementType Name="Description"/>
        <ToColumn Name="Description"/>
        </PropertyMap>
        <PropertyMap TokenList="No" ContainsXML="No">
        <ElementType Name="Collection_id"/>
        <ToColumn Name="Collection_id"/>
        </PropertyMap>
        <PropertyMap TokenList="No" ContainsXML="No">
        <ElementType Name="Collection_name"/>
        <ToColumn Name="Collection_name"/>
        </PropertyMap>
        </ClassMap>
        </Maps>
        </XMLToDBMS>

        collections.xml
        ---------------
        <Collections>
        <Collection>
        <Collection_id>1</Collection_id>
        <Collection_name>Nepal</Collection_name>
        <Description>This is a test</Description>
        </Collection>
        <Collection>
        <Collection_id>2</Collection_id>
        <Collection_name>IASCP</Collection_name>
        <Description>Test IASCP</Description>
        </Collection>
        <Collection>
        <Collection_id>3</Collection_id>
        <Collection_name>Italy6-1978</Collection_name>
        <Description>Something</Description>
        </Collection>
        <Collection>
        <Collection_id>4</Collection_id>
        <Collection_name>Workshop</Collection_name>
        <Description>test</Description>
        </Collection>
        <Collection>
        <Collection_id>6</Collection_id>
        <Collection_name>ttest</Collection_name>
        </Collection>
        <Collection>
        <Collection_id>7</Collection_id>
        <Collection_name>YingTesting</Collection_name>
        </Collection>
        </Collections>

        db.props
        --------
        #Properties for XML-DBMS
        URL=jdbc:odbc:test
        Driver=sun.jdbc.odbc.JdbcOdbcDriver
        DataSourceClass=org.xmlmiddleware.db.JDBC1DataSource
        DBName=DLCImage

        parser.props
        ------------
        #Properties for XML-DBMS
        ParserUtilsClass=org.xmlmiddleware.xmlutils.external.ParserUtilsXerces

        transfer.props
        --------------
        Method=StoreDocument
        MapFile=Collections.map
        XMLFile=Collections.xml
        ActionFile=Collections.act

        Ying Jin wrote:

        > Dear Ronald,
        >
        > Thanks for your reply. I have made the changes you
        > suggested in the following message and I'm still
        > getting the same error.
        >
        > 1. I have changed the Description column to nullable.
        > 2. Change the DTD file as you suggested.
        > 3. Change the XML file as you suggested.
        >
        > I think this time the XML file matches the DTD file.
        > Here is the SQL statement I used to create the
        > Collections table.
        >
        > CREATE TABLE Collections (
        > Collection_id INT UNSIGNED NOT NULL,
        > Collection_name VARCHAR(50) NOT NULL,
        > Description VARCHAR(500),
        > CONSTRAINT PrimaryKey PRIMARY KEY (`Collection_id`)
        > );
        >
        > I deleted all records in this table too.
        >
        > Any clue?
        >
        > Thanks very much,
        > Ying
      Your message has been successfully submitted and would be delivered to recipients shortly.