6 Replies Latest reply: Jan 30, 2009 2:19 PM by Ted Ueda RSS

Bug in setTableLocation(...) ???

Thomas Zuberbuehler
Currently Being Moderated

I think I found a bug within JRC 2. I'll post here my posting on stackoverflow.com (1).

 

After a long debugging session I found this behaviour...

 

    // incomplete code example

    for(Object table : db.getTables()) {
      
      ITable t = (ITable)((ITable)table).clone(true);
      System.out.println(t.getName());

      // modifying t, bag is an existing instance of class PropertyBag
      t.getConnectionInfo().setAttributes(bag);

      // dc is an existing instance of DatabaseController
      dc.setTableLocation((ITable)table, t)

    }

 

`db.getTables()` contains 3 tables A, B and C. If we'll run the code above `System.out` prints A, A, B to the console.

 

If we're going to comment `dc.setTableLocation((ITable)table, t)` out. A, B, C will be printed. I assume that `dc.setTableLocation((ITable)table, t)` modifies internally the list of tables.

 

We're using following workaround:

 

    // incomplete code example

    // WORKAROUND CODE
    Map<ITable, ITable> oldNewMap = new HashMap<ITable, ITable>();

    for(Object table : db.getTables()) {
      
      ITable t = (ITable)((ITable)table).clone(true);
      System.out.println(t.getName());

      // modifying t, bag is an existing instance of class PropertyBag
      t.getConnectionInfo().setAttributes(bag);

      // WORKAROUND CODE
      oldNewMap.put((ITable)table, t);

    }

    // WORKAROUND CODE
    for (Entry<ITable, ITable> e : oldNewMap.entrySet()) {
      dc.setTableLocation(e.getKey(), e.getValue());
    }

 

(1) http://stackoverflow.com/questions/479405/replace-a-database-connection-for-subreports-with-jrc

  • Re: Bug in setTableLocation(...) ???
    Ted Ueda
    Currently Being Moderated

    What's in the bag?

     

    i.e., from what to which are you changing connection info?

     

    Sincerely,

     

    Ted Ueda

  • Re: Bug in setTableLocation(...) ???
    Thomas Zuberbuehler
    Currently Being Moderated
    Map<String, String> bag = new HashMap<String, String>();
    bag.put(PropertyBagHelper.CONNINFO_JDBC_CONNECTION_URL, dhb.getConnectionUrl());
    bag.put(PropertyBagHelper.CONNINFO_SERVER_TYPE, "JDBC (JNDI)");
    bag.put(PropertyBagHelper.CONNINFO_DATABASE_DLL, "crdb_jdbc.dll");
    bag.put(PropertyBagHelper.CONNINFO_JDBC_DATABASECLASSNAME, dhb.getDatabaseDriver());

     

    dhb.getConnectionUrl() is a well-formed connection url and dhb.getDatabaseDriver() is a well-formed database driver name.

    • Re: Bug in setTableLocation(...) ???
      Ted Ueda
      Currently Being Moderated

      I'm sure it's well formed.

       

      What are the values - you're more than welcome to alter the URL to hide the server name, but I'd like to know the database type and JDBC jar file names and version.

       

      What is it changing from?

       

      Sincerely,

       

      Ted Ueda

      • Re: Bug in setTableLocation(...) ???
        Thomas Zuberbuehler
        Currently Being Moderated

        It looks like this before I change the connection information:

         

        {
          Trusted_Connection=false, 
          PreQEServerName=xxxx, 
          Server Type=Oracle Server, 
          Database DLL=crdb_oracle.dll, 
          Server Name=xxxx, Server=xxxx
        }

         

        It should look like this after I made the changes:

         

        {
          Server Type=JDBC (JNDI), 
          Database DLL=crdb_jdbc.dll, 
          Database Class Name=oracle.jdbc.driver.OracleDriver, 
          PreQEServerType=JDBC (JNDI), 
          Server Name=jdbc:oracle:thin:@LOCALHOST:1521:YYYY, 
          Connection URL=jdbc:oracle:thin:@LOCALHOST:1521:YYYY
        }

         

        BTW I'm using Oracle JDBC ojdbc14.jar.

         

        Edited by: Thomas Zuberbuehler on Jan 28, 2009 7:01 PM

  • Re: Bug in setTableLocation(...) ??? Yes, it is!!!
    IURI PEREIRA
    Currently Being Moderated

    I took several days to find the same problem.

     

    I'm using the code example (CRJavaHelper) from Business Object (JRC 2) to change the data source.

     

    The interface ITable modifies internally the order of tables.

     

    I made some changes to CRJavaHelper.changeDataSource work

     

    ...
    // Obtain collection of tables from this database controller
    if (reportName == null || reportName.equals("")) {
        Tables tables = clientDoc.getDatabaseController().getDatabase().getTables();
        
        //here the table list sort don´t change!
        ITable tabelas[] = new ITable[tables.size()];
        
        for (int i=0; i < tables.size(); i++){
             tabelas<i> = tables.getTable(i);
        }
        
        for(int i = 0;i < tabelas.length;i++){
            origTable = tabelas<i>;
            if (tableName == null || origTable.getName().equals(tableName)) {
                newTable = (ITable)origTable.clone(true);
    ...

     

     

Actions