on 01-28-2009 4:45 PM
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
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);
...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
What's in the bag?
i.e., from what to which are you changing connection info?
Sincerely,
Ted Ueda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.