• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java with Crystal Report11

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to pass a parameter from java(Swing) to Crystal Report11 without using database.

Kindely any one help me.



import java.awt.*;
import javax.swing.*;
import java.sql.*;
import java.io.*;
import java.util.*;
import com.crystaldecisions.ReportViewer.*;
import com.crystaldecisions.reports.sdk.*;
import com.crystaldecisions.sdk.occa.report.reportsource.*;
import com.crystaldecisions.sdk.occa.report.lib.*;
import com.crystaldecisions.sdk.occa.report.application.*;
import com.crystaldecisions.sdk.occa.report.data.*;

public class jtest
{

public static void createAndShowGUI() throws SQLException, ClassNotFoundException, IOException
{
System.out.println("connecting to oracle database.....");
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
java.sql.Connection c=DriverManager.getConnection("jdbc racle:thin:saralifms/o391120suman@localhost:1521 nrdifms");
System.out.println("connected to oracle database");

Statement statement = c.createStatement();
try
{
JFrame.setDefaultLookAndFeelDecorated(false);
JFrame frame= new JFrame("java report");
frame.setTitle("test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ReportViewerBean viewer= new ReportViewerBean();
viewer.init( new String[0], null, null, null);

//com.crystaldecisions.reports.sdk.ReportClientDocument rpt = new com.crystaldecisions.reports.sdk.ReportClientDocument();
com.crystaldecisions.sdk.occa.report.application.ReportClientDocument rpt = new com.crystaldecisions.sdk.occa.report.application.ReportClientDocument();//com.crystaldecisions.sdk.occa.report.application.
rpt.open("glBalanceDetails.rpt",0);

System.out.println("i am before database");
rpt.getDatabaseController().logon("saralifms", "o391120suman");
ParameterFieldController paramFieldController = rpt.getDataDefController().getParameterFieldController();
paramFieldController.setCurrentValue( "","My Parameter", new String("South 24 Pargona"));
try
{
statement.executeQuery("DROP TABLE TEMP_GL_SUMAN");
}catch(Exception e){System.out.println(e.toString());}
try
{
statement.executeQuery("CREATE TABLE TEMP_GL_SUMAN( GROUP_ID CHAR(3) NOT NULL, GROUP_NAME VARCHAR2(200), ACCOUNT_CODE VARCHAR2(11), ACCOUNT_DESC VARCHAR2(250), OPEN_BAL NUMBER(14,2), RECEIPT NUMBER(14,2), PAYMENT NUMBER(14,2), CLOSING_BAL NUMBER(14,2) ) ");
statement.executeUpdate("INSERT INTO TEMP_GL_SUMAN (SELECT GROUP_ID,GROUP_NAME,ACCOUNT_CODE,ACCOUNT_DESC,OPEN_BAL,RECEIPT,PAYMENT,CLOSING_BAL FROM MM_GL_GROUP_SUMAN,T_BALANCE_GLWISE_SUMAN WHERE MM_GL_GROUP_SUMAN.GROUP_ID=T_BALANCE_GLWISE_SUMAN.GL_GROUP) ");
}catch(Exception e){System.out.println(e.toString());}

String Query="SELECT GROUP_ID,GROUP_NAME,ACCOUNT_CODE, ACCOUNT_DESC, OPEN_BAL, RECEIPT, PAYMENT, CLOSING_BAL FROM TEMP_GL_SUMAN ORDER BY GROUP_NAME";
ResultSet resultSet = statement.executeQuery(Query);
String tableAlias = rpt.getDatabaseController().getDatabase().getTables().getTable(0).getAlias();
rpt.getDatabaseController().setDataSource(resultSet,tableAlias,"resultsetTable");

IReportSource rptSource= rpt.getReportSource();
viewer.setReportSource(rptSource);
frame.getContentPane().add(viewer,BorderLayout.CENTER);
frame.setSize(700,500);
frame.setVisible(true);
viewer.start();
}
catch(Exception exp)
{
System.out.println("hi");
System.out.println(exp.toString());
System.out.println("hi");
}
}

public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
try
{
createAndShowGUI();
}catch(Exception e){}
}
});
}
}
 
Oh. Hi guys! Look at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic