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

  • SEARCH
  • Home
  • 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 9089683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:12:19+00:00 2026-06-16T22:12:19+00:00

I have a function to print a report using crystal reports. The problem is,

  • 0

I have a function to print a report using crystal reports. The problem is, this code prints all the data from the database. How do I set a parameter or a filter programmatically so I can just select which record to present on my report. I know that theres a prompt to ask a value for the parameter on crystal reports itself but I dont want to use that.

private void openReport() {

    try {
        ReportClientDocument rpt =  new ReportClientDocument();
        rpt.open(reportPath+fileName, 0);

        rpt.getDatabaseController().logon(mdlLogin.dbUsername, mdlLogin.dbPassword);
        Tables tables = rpt.getDatabaseController().getDatabase().getTables();

        for(int i=0; i< tables.size(); i++){
            ITable table = tables.getTable(i);
            // dbane.owner.tablename
            String original_qualifiedName = table.getQualifiedName();
            String new_qualifierName = original_qualifiedName;

            switch (database) {
            case "ORACLE":
                // SCHEMA.TABLENAME
                String tableName = StringUtils.substringAfterLast(original_qualifiedName, ".").toUpperCase(); 
                new_qualifierName = userOrSchemaName.toUpperCase()+"."+tableName;

                break;
            case "INFORMIX":
                // DATABASE.OWNER.TABLENAME
                new_qualifierName = dbname + ":" + userOrSchemaName + "." + StringUtils.substringAfterLast(original_qualifiedName, ".");                    

                break;
            case "MySQL":
                // DATABASE.OWNER.TABLENAME
                new_qualifierName = dbname + "." + userOrSchemaName + "." + StringUtils.substringAfterLast(original_qualifiedName, ".");                    
                new_qualifierName = dbname + "." + StringUtils.substringAfterLast(original_qualifiedName, ".");                    
                break;
            default:
                break;
            }

            String jdbcConnectionString = null;
            String preQEServerName = null;
            String driver = null;

            switch (database) {
            case "INFORMIX":
                // !com.informix.jdbc.IfxDriver!jdbc:informix-sqli://localhost:40421/export:INFORMIXSERVER=cargool1!user={userid}!password={password}
                jdbcConnectionString = "!com.informix.jdbc.IfxDriver!jdbc:informix-sqli://"+ip+":"+port+"/"+dbname+":INFORMIXSERVER="+dbservername+"!user={userid}!password={password}";
                // jdbc:informix-sqli://localhost:40421/export:INFORMIXSERVER=cargool1
                preQEServerName      = "jdbc:informix-sqli://"+ip+":"+port+"/"+dbname+":INFORMIXSERVER="+dbservername;
                // com.informix.jdbc.IfxDriver
                driver = "com.informix.jdbc.IfxDriver";
                break;
            case "MySQL":
                // !com.mysql.jdbc.Driver!jdbc:mysql://172.20.9.170:3306/hego
                jdbcConnectionString = "!com.mysql.jdbc.Driver!jdbc:mysql://"+ip+":"+port+"/"+dbname;
                // jdbc:mysql://172.20.9.170:3306/customer
                preQEServerName      = "jdbc:mysql://"+ip+":"+port+"/"+dbname;
                // com.mysql.jdbc.Driver
                driver = "com.mysql.jdbc.Driver";
                break;
            case "ORACLE":
                // !oracle.jdbc.driver.OracleDriver!jdbc:oracle:thin:@//localhost:50000/tmsddb2
                jdbcConnectionString = "!oracle.jdbc.driver.OracleDriver!jdbc:oracle:thin:@//"+ip+":"+port+"/"+dbname;
                // jdbc:oracle:thin:@//localhost:50000/tmsddb2
                preQEServerName      = "jdbc:oracle:thin:@//"+ip+":"+port+"/"+dbname;
                // "oracle.jdbc.driver.OracleDriver"
                driver = "oracle.jdbc.driver.OracleDriver";
                break;
            default:
                break;
            }

            table.setQualifiedName(new_qualifierName);

            ConnectionInfo connInfo = new ConnectionInfo();                

            PropertyBag innerProp = new PropertyBag();
            innerProp.put("JDBC Connection String", jdbcConnectionString);
            innerProp.put("PreQEServerName",   preQEServerName);
            innerProp.put("Server Type", "JDBC (JNDI)");
            innerProp.put("Database DLL", "crdb_jdbc.dll");
            innerProp.put("Database", dbname);
            innerProp.put("Database Class Name", driver);
            innerProp.put("Use JDBC", "true");
            innerProp.put("Database Name", dbname);
            innerProp.put("Server Name", preQEServerName);
            innerProp.put("Connection URL", preQEServerName);

            connInfo.setAttributes(innerProp);
            connInfo.setUserName(mdlLogin.dbUsername);
            connInfo.setPassword(mdlLogin.dbPassword);

            table.setConnectionInfo(connInfo);
            rpt.getDatabaseController().setTableLocation(table, tables.getTable(i));
        }
        /*
         * SubReport
         * 
         */

        int numTables = rpt.getSubreportController().getSubreportNames().size();

        for(int i=0; i<numTables; i++){////////////

            String str = rpt.getSubreportController().getSubreportNames().getString(i);

            Tables subTables = rpt.getSubreportController().getSubreport(str).getDatabaseController().getDatabase().getTables();

            for(int j=0; j< subTables.size(); j++){
                ITable table = subTables.getTable(j);
                // dbane.owner.tablename
                String original_qualifiedName = table.getQualifiedName();
                String new_qualifierName = original_qualifiedName;

                switch (database) {
                case "ORACLE":
                    // SCHEMA.TABLENAME
                    String tableName = StringUtils.substringAfterLast(original_qualifiedName, ".").toUpperCase(); 
                    new_qualifierName = userOrSchemaName.toUpperCase()+"."+tableName;

                    break;
                case "INFORMIX":
                    // DATABASE.OWNER.TABLENAME
                    new_qualifierName = dbname + ":" + userOrSchemaName + "." + StringUtils.substringAfterLast(original_qualifiedName, ".");                    

                    break;
                case "MySQL":
                    // DATABASE.OWNER.TABLENAME
//                    new_qualifierName = dbname + "." + userOrSchemaName + "." + StringUtils.substringAfterLast(original_qualifiedName, ".");                    
                    new_qualifierName = dbname + "." + StringUtils.substringAfterLast(original_qualifiedName, ".");                    
                    break;
                default:
                    break;
                }

                String jdbcConnectionString = null;
                String preQEServerName = null;
                String driver = null;

                switch (database) {
                case "INFORMIX":
                    // !com.informix.jdbc.IfxDriver!jdbc:informix-sqli://localhost:40421/export:INFORMIXSERVER=cargool1!user={userid}!password={password}
                    jdbcConnectionString = "!com.informix.jdbc.IfxDriver!jdbc:informix-sqli://"+ip+":"+port+"/"+dbname+":INFORMIXSERVER="+dbservername+"!user={userid}!password={password}";
                    // jdbc:informix-sqli://localhost:40421/export:INFORMIXSERVER=cargool1
                    preQEServerName      = "jdbc:informix-sqli://"+ip+":"+port+"/"+dbname+":INFORMIXSERVER="+dbservername;
                    // com.informix.jdbc.IfxDriver
                    driver = "com.informix.jdbc.IfxDriver";
                    break;
                case "MySQL":
                    // !com.mysql.jdbc.Driver!jdbc:mysql://172.20.9.170:3306/hego
                    jdbcConnectionString = "!com.mysql.jdbc.Driver!jdbc:mysql://"+ip+":"+port+"/"+dbname;
                    // jdbc:mysql://172.20.9.170:3306/customer
                    preQEServerName      = "jdbc:mysql://"+ip+":"+port+"/"+dbname;
                    // com.mysql.jdbc.Driver
                    driver = "com.mysql.jdbc.Driver";
                    break;
                case "ORACLE":
                    // !oracle.jdbc.driver.OracleDriver!jdbc:oracle:thin:@//localhost:50000/tmsddb2
                    jdbcConnectionString = "!oracle.jdbc.driver.OracleDriver!jdbc:oracle:thin:@//"+ip+":"+port+"/"+dbname;
                    // jdbc:oracle:thin:@//localhost:50000/tmsddb2
                    preQEServerName      = "jdbc:oracle:thin:@//"+ip+":"+port+"/"+dbname;
                    // "oracle.jdbc.driver.OracleDriver"
                    driver = "oracle.jdbc.driver.OracleDriver";
                    break;
                default:
                    break;
                }

                table.setQualifiedName(new_qualifierName);

                ConnectionInfo connInfo = new ConnectionInfo();                

                PropertyBag innerProp = new PropertyBag();
                innerProp.put("JDBC Connection String", jdbcConnectionString);
                innerProp.put("PreQEServerName",   preQEServerName);
                innerProp.put("Server Type", "JDBC (JNDI)");
                innerProp.put("Database DLL", "crdb_jdbc.dll");
                innerProp.put("Database", dbname);
                innerProp.put("Database Class Name", driver);
                innerProp.put("Use JDBC", "true");
                innerProp.put("Database Name", dbname);
                innerProp.put("Server Name", preQEServerName);
                innerProp.put("Connection URL", preQEServerName);

                connInfo.setAttributes(innerProp);
                connInfo.setUserName(mdlLogin.dbUsername);
                connInfo.setPassword(mdlLogin.dbPassword);

                table.setConnectionInfo(connInfo);
                rpt.getSubreportController().getSubreport(str).getDatabaseController().setTableLocation(table, subTables.getTable(j));
            }
        }//////////////////////////

//            rpt.getPrintOutputController().export(ReportExportFormat.RTF)

        ReportViewerBean viewer = new ReportViewerBean();
        viewer.init(new String[0], null, null, null);
        viewer.setHasGroupTree(false);
        viewer.setReportSource(rpt.getReportSource());
        viewer.setHasExportButton(false);
        viewer.setShowLogo(false);
        viewer.start();
        frmReportPanel panel = new frmReportPanel(rpt,fileName.replace(".rpt", ""));

        Component[] components = viewer.getContentPane().getComponents();

        panel.setLayout(new BorderLayout());

        panel.add(components[0], BorderLayout.NORTH);
        panel.add(components[1], BorderLayout.CENTER);

        clsMain.openTab(fileName.replace(".rpt", ""), panel);


    } catch (HeadlessException | ReportSDKExceptionBase | PropertyVetoException exception) {
        Logger.getLogger(frmReportList.class.getName()).log(Level.SEVERE, null, exception);
        utilErrorHandler.printError(exception.toString(), exception.getMessage(), M_STRPANELNAME, "PrintReport");
    }
}
  • 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-16T22:12:20+00:00Added an answer on June 16, 2026 at 10:12 pm

    I was able to answer it by these codes

    ParameterFieldController paramController=rpt.getDataDefController().getParameterFieldController();
    paramController.setCurrentValue("",parameterField,Integer.parseInt(parameterValue));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a function to print database table to an array like this
hi i have a function that get information from xml data and print markers
I have this piece of code in a function. I want to print the
I have this peculiar problem while wanting to print a html-report. The file itself
say I have this class: class animal { function noise() { print 'woof'; }
I have a foreach function which permits me to print fields in a database,
So I have this code which is called in a print_info() function after a
I have some vb.net code which should print out labels using Teklynx LabelView software
I have something like this: function print_element($array, $field){ return Element: {$array[$field]}; } $array['name_en'] =
Assume I have the function: function name_the_paramlist(varargin) % Print out varargin exactly how it

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.