Skip to Content
0
Former Member
May 06, 2010 at 01:17 PM

Correct Schema translation for DB2 Database.

35 Views

Hi,

I am trying to change a reports runtime datasource using CR4E 2.0 jars. settableloccation method.

The reports are based on command objects.

code am using is:

final String TABLE_NAME_QUALIFIER = "SSS.";

final String SERVERNAME = "136.51.30.145";

final String CONNECTION_STRING ="!com.ibm.db2.jcc.DB2Driver!jdbc:db2://136.51.30.145:60000/UniQMI_H:retrieveMessagesFromServerOnGetMessage=true;!user=!password={pass@123}!ServerType=5!QuoteChar=\"";

final String DATABASE_CLASS_NAME = "com.ibm.db2.jcc.DB2Driver";

final String DATABASE_DLL = "crdb_jdbc.dll";

final String DBURI = "!com.ibm.db2.jcc.DB2Driver!jdbc:db2://136.51.30.145:60000/UNIQMI_H!ServerType=5!QuoteChar=\"";

final String DBUSERNAME = "user";

final String DBPASSWORD = "pass@123";

Tables tables = databaseController.getDatabase().getTables();

System.out.println("Table Size="+tables.size());

System.out.println(tables.getTable(0).getClass().getCanonicalName() );

ICommandTable oldtable = (ICommandTable)tables.getTable(0);

System.out.println(oldtable.getName());

oldtable.setName("Command");

oldtable.setAlias("Command");

System.out.println(oldtable.getAlias());

oldtable.setQualifiedName(TABLE_NAME_QUALIFIER+"Command");

System.out.println(oldtable.getQualifiedName());

IConnectionInfo connectionInfo = oldtable.getConnectionInfo();

PropertyBag innerProp = connectionInfo.getAttributes();

System.out.println(innerProp);

innerProp.clear();

PropertyBag propertyBag = new PropertyBag();

propertyBag.put("Trusted_Connection", "b(false)");

propertyBag.put("Server Name", SERVERNAME);

propertyBag.put("Connection String", CONNECTION_STRING);

propertyBag.put("Server Type", "JDBC (JNDI)");

propertyBag.put("Database Class Name", DATABASE_CLASS_NAME);

propertyBag.put("Use JDBC", "true");

propertyBag.put("URI", DBURI);

propertyBag.put("Database DLL", DATABASE_DLL);

connectionInfo.setAttributes(propertyBag);

connectionInfo.setUserName("user");

connectionInfo.setPassword("pass@123");

connectionInfo.setKind(ConnectionInfoKind.SQL);

oldtable.setConnectionInfo(connectionInfo);

databaseController.setTableLocation(oldtable,tables.getTable(0));

Can some one figure out where I am wrong?

Is the Schem Translation correct?

Regards,

Jon