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

3537Re: Problem compiling filter for v2 generated Map

Expand Messages
  • rwriddle
    Aug 2, 2004
      To keep from holding up my project, I got my code running with
      specific references to "COLL" by setting the database properties as
      attributes on the ResultSetInfo Filter element:


      <?xml version="1.0"?>
      <FilterSet Version="2.0"
      <Wrapper Name="CAMPAIGNS" Table="CAMPAIGN"/>
      <ResultSetInfo Name="CampaignsRS" Database="COLL" Schema="DB2ADMIN"
      Table="CAMPAIGN" />


      But when I was cleaning up my examples and went back to revise the
      code to match your recommendation of using "Default" instead of
      specifying a database while setting up dbProps, I hit a snag.

      Both setting the property value to "Default" instead of "COLL" and
      also completely commenting out the line:

      > dbProps.setProperty("DBName", JDBC_DBNAME);

      lead to null pointer exceptions later when the "createMapFromDatabase"
      method is called:


      That exception is on line 1195 of the getDatabaseMetaData method of
      MapFactory_Database.java in the the CVS tip version of XML-DBMS Alpha
      2 which reads:

      meta = conn.getMetaData();

      I also tried literally setting the DBName property to null as in
      "dbProps.setProperty("DBName", null)." That just caused a
      Hashtable.put exception.


      I assume that the code will later attempt to match the dbProps with
      the "rootDatabaseNames", but I tried both nulling out the
      "rootDatabaseName" string array and passing in a string array
      consisting of one null string without success.

      I have two questions about the "root" entries on the
      XMLDBMSMap.createMapFromDatabase() method call:

      1. What other parms have to match with a null or "Default" database
      name on the dbProps "DBName" property? (RootDatabaseName, etc.)? (And
      did you mean passing in "null" or explicitly passing in "Default"?)

      2. What exactly are the rolls of the various rootDatabaseNames,
      rootSchemaNames, and rootTables?

      A search of the Yahoo groups for "rootDatabaseName" turned up no new
      messages and the MapFactory_Database documentation says simply:

      rootDatabaseNames - Names of the root databases. If any entries are
      null, the name "Default" is used.
      rootCatalogNames - Names of the root catalogs. Entries may be null.
      rootSchemaNames - Names of the root schemas. Entries may be null.
      rootTableNames - Names of the root tables.

      But does not explain what are the implications of the "root"
      designation and when or if the various "root" name string arrays are

      ============ My createMap() method reads:

      public org.xmlmiddleware.xmldbms.maps.XMLDBMSMap createMap(String
      aMapFileName, boolean saveToFile) {
      try {

      Properties dbProps = new Properties();

      dbProps.setProperty("Driver", JDBC_DRIVER);
      dbProps.setProperty("URL", JDBC_URL);
      dbProps.setProperty("User", JDBC_USER);
      dbProps.setProperty("Password", JDBC_PASSWORD);
      dbProps.setProperty("DataSourceClass", JDBC_DATASOURCE);
      // dbProps.setProperty("DBName", JDBC_DBNAME);

      Properties configProps = new Properties();

      configProps.setProperty("MapColumnsAs", "ElementTypes");
      configProps.setProperty("FollowPrimaryKeys", "Yes");
      configProps.setProperty("FollowForeignKeys", "Yes");

      ParserUtils utils = null;

      utils = (ParserUtils) Class.forName(PARSERUTILSCLASS).

      MapManager mm = new MapManager(utils);

      String[] rootDatabaseNames = {JDBC_DBNAME};
      String[] rootSchemaNames = {JDBC_SCHEMANAME};
      String[] rootTableNames = {JDBC_TABLENAME};

      org.xmlmiddleware.xmldbms.maps.XMLDBMSMap map =
      null, // String rootCatalogNames[],
      null, // String stopDatabaseNames[],
      null, // String stopCatalogNames[],
      null, // String stopSchemaNames[],
      null // String stopTableNames[]
      return map;
      catch (Exception ex) {
      return null;

      --- In xml-dbms@yahoogroups.com, rpbourret@r... wrote:
      > I only had time to look at this quickly, but the problem is with the
      > name. In the map file, you set it to COLL, but in the filter file,
      you don't
      > specify it, so Default is used. (You need to specify the database
      name with the
      > Database attribute of the Table element in your filter file.)
      > As a general rule, you should not use database names in XML-DBMS
      unless your
      > data is stored across multiple physical databases, such as two
      different DB2
      > installations or a DB2 server and an Oracle server. Database names
      in XML-DBMS
      > are purely logical names used to keep track of which physical
      database to use;
      > they do not correspond to database names on databases. (If those
      even exist,
      > they are more likely to correspond to JDBC catalog names -- see your
      > driver's documentation to be sure.)
      > See comments below.
      > -- Ron
      > [snip]
      > This should be COLL, which is the logical name used by your map
      > > dbProps.setProperty("DBName", JDBC_DBNAME);
      > This is COLL (which is correct). However, note that the database
      name in XML-DBMS is not related to the database name used by DB2. You
      would probably be better off to not use a database name in XML-DBMS at
      all, since you are using only one physical database. (That way,
      everything defaults to the database name "Default" and will just

      > [snip]
    • Show all 3 messages in this topic