Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Crystal Report with Java

843859Jul 31 2007
Hi

I m using NetBeans for Java(Swing+JDBC) development
I wana call Crystal Report file (.rpt) file from Java
I found following source on Sun Forums:-
import java.awt.*;
import javax.swing.*;
import com.crystaldecisions.ReportViewer.*;

// Use these to talk to RAS
import com.crystaldecisions.sdk.occa.report.application.*;
import com.crystaldecisions.sdk.occa.report.reportsource.*;


public class HelloWorldSwing
{
    private static void createAndShowGUI()
    {
        try
        {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(false);

            //Create and set up the window.
            JFrame frame = new JFrame("HelloWorldSwing");
            frame.setTitle( "Testing 1, 2, 3");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            ReportViewerBean	viewer = new ReportViewerBean();
            viewer.init( new String[0], null, null, null);

            ReportClientDocument	rpt = new ReportClientDocument();

            // FLui: set the RAS server if you are using RAS 
            rpt.setReportAppServer( "localhost" );
            rpt.open( "ras://C:\\Reports\\MyReport.rpt", 0 );

            IReportSource	rptSource = rpt.getReportSource();
            viewer.setReportSource( rptSource );

            frame.getContentPane().add( viewer, BorderLayout.CENTER );
            frame.setSize( 700, 500 );
            frame.setVisible(true);

            viewer.start();
        }
        catch ( Exception exception )
        {
            System.out.println( exception.toString() );
        }
    }

    public static void main(String[] args) 
    {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        //com.crystaldecisions.ReportViewer.ReportViewerFrame.main( args );
        javax.swing.SwingUtilities.invokeLater(new Runnable() 
        {
            public void run() 
            {
                createAndShowGUI();
            }
        });
    }
}
Presently I need ReportViewer.jar
If any one have, please give me at <gajeshtripathi@sangamflock.com>

Also guide me how we can pass sql & parameters to Crystal Report
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 28 2007
Added on Jul 31 2007
0 comments
240 views