Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7987935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:17:28+00:00 2026-06-04T12:17:28+00:00

I have this code import com.crystaldecisions.reports.sdk.ReportClientDocument; … ReportClientDocument rpt = new ReportClientDocument(); rpt.open(reportPath+fileName, 0);

  • 0

I have this code

import com.crystaldecisions.reports.sdk.ReportClientDocument;
...

ReportClientDocument rpt =  new ReportClientDocument();
    rpt.open(reportPath+fileName, 0);
    rpt.getDatabaseController().logon(DBConnect.getUsername(), DBConnect.getPassword());
    Tables tables = rpt.getDatabaseController().getDatabase().getTables();

    for(int i=0; i< tables.size(); i++){
        System.out.print(i);
        ITable table = tables.getTable(i);

        IConnectionInfo connInfo = table.getConnectionInfo();

        PropertyBag innerProp = connInfo.getAttributes();
        innerProp.clear();

        PropertyBag propertyBag = new PropertyBag();
        propertyBag.put("Server Type", "JDBC (JNDI)");
        propertyBag.put("Database DLL", "crdb_jdbc.dll");
        propertyBag.put("Connection String", DBConnect.getConnectionString());
        propertyBag.put("Database Class Name", "com.mysql.jdbc.Driver");
        propertyBag.put("Use JDBC", "true");
        propertyBag.put("Server Name", DBConnect.getServer());
        propertyBag.put("Generic JDBC Driver Behavior", "No");
        propertyBag.put("URI", "!com.mysql.jdbc.Driver!jdbc:mysql://"+DBConnect.getServer()+":"+DBConnect.getPort()+"/"+DBConnect.getDatabase()+"!ServerType=29!QuoteChar=`");

        connInfo.setAttributes(propertyBag);
        connInfo.setKind(ConnectionInfoKind.SQL);

        table.setConnectionInfo(connInfo);
        rpt.getDatabaseController().setTableLocation(table, tables.getTable(i));

What Im trying to do is to open a report and pass the connection info to that report so that I can dynamically change the database of the report but for some reason it is not working and the report still produces the information from the database that it was initially set up. Can someone please tell me what I did wrong? This is a swing application and I am using crystal reports XI. Btw Im using com.crystaldecisions.reports.sdk.ReportClientDocument instead of com.crystaldecisions.sdk.occa.report.application.ReportClientDocument because when I use the other one, I get a cannot find server error. Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:17:29+00:00Added an answer on June 4, 2026 at 12:17 pm

    To switch connection at runtime you can use this:

    IConnectionInfo oldConnInfo = new ConnectionInfo();
    IConnectionInfo newConnInfo = new ConnectionInfo();
    
    // If this connection needed parameters, we would use this field.   
    com.crystaldecisions.sdk.occa.report.data.Fields pFields = null;
    
    try{
        // Assign the old Connection info to the reports current info
        //DatabaseController dbController = rptClient.getDatabaseController();
        oldConnInfo=dbController.getConnectionInfos(null).getConnectionInfo(0);
        com.crystaldecisions.sdk.occa.report.lib.PropertyBag boPropertyBag1 = new com.crystaldecisions.sdk.occa.report.lib.PropertyBag();
        boPropertyBag1.put("JDBC Connection String","...");
        boPropertyBag1.put("Server Type","...");
        boPropertyBag1.put("Database Type","...");
        boPropertyBag1.put("Database Class Name","...");
        boPropertyBag1.put("Use JDBC","...");
        boPropertyBag1.put("Connection URL","...");
        boPropertyBag1.put("Database DLL","...");
        // Assign the properties to the connection info
        newConnInfo.setAttributes(boPropertyBag1);
        // Set the DB Username and Pwd
        newConnInfo.setUserName("...");
        newConnInfo.setPassword("...");    
        // The Kind of connectionInfos is SQL
        newConnInfo.setKind(ConnectionInfoKind.SQL);
    
        // set the parameters to replace.
        // The 4 options are:
        // _doNotVerifyDB 
        // _ignoreCurrentTableQualifiers 
        // _mapFieldByRowsetPosition 
        // _useDefault  
        int replaceParams = DBOptions._ignoreCurrentTableQualifiers + DBOptions._doNotVerifyDB;
        // Now replace the connections
        dbController.replaceConnection(oldConnInfo, newConnInfo, pFields, replaceParams);
        }catch(ReportSDKException rse){
        ...
        }
    

    Pass appropriate values in the above code snippet. Sorry that this uses com.crystaldecisions.sdk.occa.report APIs.

    Hope this helps…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: package com.powergroupbd.timer; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.os.CountDownTimer;
I have this simple twill code >>> from twill.commands import * >>> go(http://stackoverflow.com:80) ==>
i have this code package com.tct.soundTouch; import android.app.Activity; import android.media.MediaPlayer; import android.os.Bundle; import android.view.MotionEvent;
I have been running this code (from: http://blog.somethingaboutcode.com/?p=155 ): from twisted.internet import reactor from
I have this (smart code): import com.mongodb.casbah.Imports._ import com.mongodb.casbah.util.bson.conversions._ RegisterJodaTimeConversionHelpers() //error object Main {
I have this code: package com.problemio; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View;
I have this code: package com.problemio; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList;
I have this code package com.cerbertek; import java.util.ArrayList; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory;
I have this import in my code : import com.sun.jdmk.cascading.CascadingAgent but I get this
I have this import in my code: import com.sun.jmx.snmp.SnmpOidDatabaseSupport; but i get following error:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.