//Declare the new connection properties that report's datasource will be switched to.
//NOTE: These are specific to using JDBC against a particular MS SQL Server database. Be sure to use the
//DisplayConnectionInfo sample to determine what your own connection properties need to be set to.
final String TABLE_NAME_QUALIFIER = "xtreme.dbo.";
final String DBUSERNAME = "devtech";
final String DBPASSWORD = "devtech";
final String SERVERNAME = "vancsdb02.crystald.net";
final String CONNECTION_STRING = "Use JDBC=b(true);Connection URL=s(jdbc:microsoft:sqlserver://vancsdb02.crystald.net:1433);" +
"Database Class Name=s(com.microsoft.jdbc.sqlserver.SQLServerDriver);Server=s(vancsdb02.crystald.net);" +
"User ID=s(vantech);Password=;Database=s(Xtreme1);Trusted_Connection=b(false);" +
"JDBC Connection String=s(!com.microsoft.jdbc.sqlserver.SQLServerDriver!jdbc:microsoft:sqlserver://vancsdb02.crystald.net:1433;" +
"DatabaseName={database};user={userid};password={password}!)";
final String DATABASE_NAME = "Xtreme";
final String URI = "!com.microsoft.jdbc.sqlserver.SQLServerDriver!jdbc:microsoft:sqlserver://vancsdb02.crystald.net:1433;DatabaseName={database};user={userid};password={password}!";
final String DATABASE_DLL = "crdb_jdbc.dll";
//Obtain collection of tables from this database controller.
Tables tables = databaseController.getDatabase().getTables();
//Set the datasource for all main report tables.
for (int i = 0; i < tables.size(); i++) {
ITable table = tables.getTable(i);
//Keep existing name and alias.
table.setName(table.getName());
table.setAlias(table.getAlias());
//Change properties that are different from the original datasource.
table.setQualifiedName(TABLE_NAME_QUALIFIER + table.getName());
//Change connection information properties.
IConnectionInfo connectionInfo = table.getConnectionInfo();
//Set new table connection property attributes.
PropertyBag propertyBag = new PropertyBag();
//Set database username and password.
//NOTE: Even if these the username and password properties don't change when switching databases, the
//database password is *not* saved in the report and must be set at runtime if the database is secured.
connectionInfo.setUserName(DBUSERNAME);
connectionInfo.setPassword(DBPASSWORD);
connectionInfo.setKind(ConnectionInfoKind.SQL);
table.setConnectionInfo(connectionInfo);
//Update old table in the report with the new table.
databaseController.setTableLocation(table, tables.getTable(i));