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

Re: Ms Access& JDBC-ODBC

Expand Messages
  • fbsilva@yahoo.com
    Hi Ron, Thanks very much for your quick response.. Much appreciated!! Could the following be the problem with connecting to Microsoft Access?? Here is a
    Message 1 of 6 , Jan 31, 2001
    • 0 Attachment
      Hi Ron,
      Thanks very much for your quick response.. Much appreciated!!
      Could the following be the problem with connecting to Microsoft
      Access??
      Here is a snippet of the code in Transfer.java
      Why are there 2-conn strings?? conn1 & conn2. Can't we use the same
      conn1 for creating the map object also...

      Thanks in advance

      static void toDBMS(String mapFilename, String xmlFilename, String
      url)
      throws Exception
      {
      Connection conn1 = null, conn2 = null;
      Map map;
      Document doc;
      DOMToDBMS domToDBMS;
      KeyGeneratorImpl keyGenerator = null;

      try
      {
      // Get a JDBC driver. You will need to modify this code if
      // you are using a different driver.
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      // Class.forName("easysoft.sql.jobDriver");

      // Connect to the database.
      conn1 = DriverManager.getConnection(url);
      conn2 = DriverManager.getConnection(url);

      // Create and initialize a key generator
      keyGenerator = new KeyGeneratorImpl(conn1);
      keyGenerator.initialize();

      // Create the Map object and open the XML document.
      map = createMap(mapFilename, conn2);
      doc = openDocument(xmlFilename);



      --- In xml-dbms@y..., Ronald Bourret <rpbourret@r...> wrote:
      > Hmmmm. I tried this locally with Access and didn't have a problem,
      so it
      > looks like the map file is correct. I can only think of two possible
      > errors:
      >
      > 1) You are connecting to a different database than the one you
      think you
      > are connecting to. If you have not modified Transfer.java, then you
      need
      > an ODBC data source named xmldbms that points to the Access .mdb
      file
      > containing these tables.
      >
      > 2) There is a spelling error somewhere -- that is, a name in the
      > database doesn't match a name in the map file.
      >
      > Can you get Transfer to work with the sample data?
      >
      > Also, you are going to have two problems with this map file and
      this XML
      > document:
      >
      > 1) You need to declare ADD_INVOICE as an ignored root in the map
      file.
      > See sales.map for a sample of how this is done.
      >
      > 2) The map won't work with the XML document. This is because
      SODETAIL is
      > a sibling of SOHEADER, but you have it listed as a related class of
      > SOHEADER. To be a related class, SODETAIL should be a child of
      SOHEADER.
      > That is, the structure of your XML document needs to be:
      >
      > <ADD_INVOICE>
      > <SOHEADER>
      > ... header elements
      > <SODETAIL>
      > ...detail elements...
      > </SODETAIL>
      > </SOHEADER>
      > <ADD_INVOICE>
      >
      > not:
      >
      > <ADD_INVOICE>
      > <SOHEADER>
      > ... header elements
      > </SOHEADER>
      > <SODETAIL>
      > ...detail elements...
      > </SODETAIL>
      > <ADD_INVOICE>
      >
      > Another alternative is to eliminate the SOHEADER element and map
      > ADD_INVOICE directly to the SALESORDERHEADER table:
      >
      > <ADD_INVOICE>
      > ... header elements
      > <SODETAIL>
      > ...detail elements...
      > </SODETAIL>
      > <ADD_INVOICE>
      >
      > -- Ron
      >
      > fbsilva@y... wrote:
      > >
      > > The error msg:
      > > de.tudarmstadt.ito.xmldbms.InvalidMapException: Table not found:
      > > SALESORDERDETAIL. Check that the table exists, that its name is
      > > spelled correctly, and that the case used in the map document
      exactly
      > > matches the case used in the database. This might be different
      from
      > > the case you used when creating the table.
      >
      > --
      > Ronald Bourret
      > Programming, Writing, and Training
      > XML, Databases, and Schemas
      > http://www.rpbourret.com
    • Ronald Bourret
      Unfortunately, this isn t the problem. Did you check that you are connecting to the correct .mdb and that you can run the samples? As to the code in Transfer,
      Message 2 of 6 , Feb 1, 2001
      • 0 Attachment
        Unfortunately, this isn't the problem. Did you check that you are
        connecting to the correct .mdb and that you can run the samples?

        As to the code in Transfer, one Connection is used by the Map object.
        This is the connection on which data is actually transferred by
        DOMToDBMS and DBMSToDOM.

        The second Connection is used by KeyGeneratorImpl, which is an object
        used to generate primary keys. This object is only used if the map
        document contains a CandidateKey element in which the value of the
        Generate attribute is "Yes". You map document does not use this feature,
        so you may safely comment out this code if you want.

        // conn1 = DriverManager.getConnection(url);
        conn2 = DriverManager.getConnection(url);

        // Create and initialize a key generator
        // keyGenerator = new KeyGeneratorImpl(conn1);
        // keyGenerator.initialize();

        -- Ron

        fbsilva@... wrote:
        >
        > Hi Ron,
        > Thanks very much for your quick response.. Much appreciated!!
        > Could the following be the problem with connecting to Microsoft
        > Access??
        > Here is a snippet of the code in Transfer.java
        > Why are there 2-conn strings?? conn1 & conn2. Can't we use the same
        > conn1 for creating the map object also...
        >
        > Thanks in advance
        >
        > static void toDBMS(String mapFilename, String xmlFilename, String
        > url)
        > throws Exception
        > {
        > Connection conn1 = null, conn2 = null;
        > Map map;
        > Document doc;
        > DOMToDBMS domToDBMS;
        > KeyGeneratorImpl keyGenerator = null;
        >
        > try
        > {
        > // Get a JDBC driver. You will need to modify this code if
        > // you are using a different driver.
        > Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        > // Class.forName("easysoft.sql.jobDriver");
        >
        > // Connect to the database.
        > conn1 = DriverManager.getConnection(url);
        > conn2 = DriverManager.getConnection(url);
        >
        > // Create and initialize a key generator
        > keyGenerator = new KeyGeneratorImpl(conn1);
        > keyGenerator.initialize();
        >
        > // Create the Map object and open the XML document.
        > map = createMap(mapFilename, conn2);
        > doc = openDocument(xmlFilename);
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.