473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Connecting Crystal Reports in NetBeans

I am using NetBeans 5.0.I tried to connect MySQL with Crystal Reports XI.When writing the coding in Java Application.I get the following error.
com.crystaldecisions.sdk.occa.report.lib.ReportSDK Exception: Unexpected error determining relative path---- Error code:-2147217395 Error code name:serverProgrammingError
Could anyone help me to solve this problem.
My Codings
Expand|Select|Wrap|Line Numbers
  1. import com.crystaldecisions.reports.sdk.*;
  2. import com.crystaldecisions.sdk.occa.report.lib.*;
  3.  
  4. //Java Imports.
  5. import javax.swing.*;
  6.  
  7. import java.sql.*;
  8.  
  9. public class JRCResultsetDatasource {
  10.  
  11.     private static final String REPORT_NAME = "C:\\Rathna_project\\financial_accounting\\JavaApplication20\\docrep.rpt";
  12.  
  13.     public static void launchApplication() {
  14.  
  15.         try {
  16.  
  17.             //Open report.
  18.             ReportClientDocument reportClientDoc = new ReportClientDocument();
  19.             reportClientDoc.open(REPORT_NAME, 0);
  20.  
  21.             //Create SQL query.     
  22.             String query = "SELECT S_C_DOC_TYPE,S_C_DOC_NO FROM inventory.document_master";
  23.  
  24.             //Query database and obtain the Resultset that will be pushed into the report.   
  25.             ResultSet resultSet = getResultSetFromQuery(query, ResultSet.TYPE_SCROLL_INSENSITIVE); 
  26.  
  27.             //Look up existing table in the report to set the datasource for and obtain its alias.  This table must 
  28.             //have the same schema as the Resultset that is being pushed in at runtime.  The table could be created 
  29.             //from a Field Definition File, a Command Object, or regular database table.  As long the Resultset
  30.             //schema has the same field names and types, then the Resultset can be used as the datasource for the table.  
  31.             String tableAlias = reportClientDoc.getDatabaseController().getDatabase().getTables().getTable(0).getAlias();
  32.  
  33.             //Push the Java ResultSet into the report.  This will then be the datasource of the report.
  34.             reportClientDoc.getDatabaseController().setDataSource(resultSet, tableAlias , "resultsetTable");
  35.  
  36.             //Launch JFrame that contains the report viewer.
  37.             new ReportViewerFrame(reportClientDoc);        
  38.  
  39.         }
  40.         catch(ReportSDKException ex) {    
  41.             System.out.println(ex);
  42.         }
  43.         catch(Exception ex) {
  44.             System.out.println(ex);            
  45.         }
  46.  
  47.     }
  48.  
  49.     /**
  50.      * Simple utility function for obtaining result sets that will be pushed into the report.  
  51.      * This is just standard querying of a Java result set and does NOT involve any 
  52.      * Crystal JRC SDK functions.  
  53.      */
  54.     private static ResultSet getResultSetFromQuery(String query, int scrollType) throws SQLException, ClassNotFoundException {
  55.         try {
  56.  
  57.             //Load JDBC driver for the database that will be queried.  
  58.             Class.forName("com.mysql.jdbc.Driver").newInstance();
  59.         } catch (InstantiationException ex) {
  60.             ex.printStackTrace();
  61.         } catch (IllegalAccessException ex) {
  62.             ex.printStackTrace();
  63.         } catch (ClassNotFoundException ex) {
  64.             ex.printStackTrace();
  65.         }
  66.  
  67.         //Construct JDBC connection.
  68.         //final String DBUSERNAME = "root";
  69.         //final String DBPASSWORD = "";
  70.         final String CONNECTION_URL = "jdbc:mysql://localhost:3306/inventory?user=root";
  71.  
  72.         java.sql.Connection connection = DriverManager.getConnection(CONNECTION_URL); 
  73.         Statement statement = connection.createStatement(scrollType, ResultSet.CONCUR_READ_ONLY);
  74.  
  75.         //Execute query and return result sets.
  76.         return statement.executeQuery(query);
  77.  
  78.     }
  79.  
  80.     public static void main(String [] args) {
  81.  
  82.         //Event-dispatching thread to run Swing GUI.  This is good practice for Swing applications
  83.         //to help ensure that events are dispatched in a predicatable order. 
  84.         //For more information on using this method, refer to the SUN site below for more details:
  85.         //http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html
  86.         SwingUtilities.invokeLater(new Runnable() { 
  87.             public void run() {
  88.                 //Hand-off to worker function to start application.
  89.                 launchApplication();                
  90.             }
  91.         });
  92.  
  93.     }
  94.  
  95. }
Feb 9 '08 #1
2 19459
Hello,

I am alaso facing the same problem and i am using it in a web application. Please let me know if you have found the solution.

Thank you
Ganesh
Jul 1 '09 #2
hello sir,

i send you some code and you run this ...
i think it is usefull for you....

mport java.io.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
class Form extends JFrame{

JButton add;
JPanel panel,pan;
JLabel label1,label2,label3,label4,label5;
final JTextField text1,text2,text3,text4,text5;
Form() {
label1 = new JLabel();
label1.setText("Employee Id:");
text1 = new JTextField(20);

label2 = new JLabel();
label2.setText("Employee Name:");
text2 = new JTextField(20);

label3 = new JLabel();
label3.setText("Employee Designation:");
text3 = new JTextField(20);

label4 = new JLabel();
label4.setText("Employee Salary:");
text4 = new JTextField(20);

label5 = new JLabel();
label5.setText("Employee Address:");
text5 = new JTextField(20);

ADD=new JButton("Print");

panel=new JPanel(new GridLayout(6,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(label3);
panel.add(text3);
panel.add(label4);
panel.add(text4);
panel.add(label5);
panel.add(text5);
panel.add(ADD);
add(panel,BorderLayout.CENTER);
setTitle("FORM");

ADD.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String id[]={text1.getText()};
String name[]={text2.getText()};
String des[]={text3.getText()};
String sal[]={text4.getText()};
String add[]={text5.getText()};

java.util.List<String> list = new ArrayList<String>();
for(int i = 0; i < id.length; i++) {
String line = id[i]+" "+name[i]+" "+des[i]+" "+sal[i]+" "+add[i];
list.add(line);
}
writeToFile(list, "Employee.txt");
JOptionPane.showMessageDialog(null,"Inserted into File");
text1.setText(" ");
text2.setText(" ");
text3.setText(" ");
text4.setText(" ");
text5.setText(" ");

}
});
}
private static void writeToFile(java.util.List<String> list, String path) {
BufferedWriter out = null;
try {
File file = new File(path);
out = new BufferedWriter(new FileWriter(file,true));
for (String s : list) {
out.write(s);
out.newLine();
}
out.close();
} catch(IOException e) {}
}
}
class InsertToFile{
public static void main(String arg[]) {
try
{
Form frame=new Form();
frame.setSize(300,300);
frame.setVisible(true);
}
catch(Exception e)
{}
}
}
Apr 8 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Gheaci Maschl | last post by:
Hi all! I would like to have your opinion about my problem and my proposal how to solve it: Ingredients: - BTriev database - Crystal Reports - maybe MS Access - Liinos6 (small ERP software)
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
3
by: VMI | last post by:
I know this may not be the best NG for this, but I feel you guys know more about this than any of the other NGs. I need to build several simple reports (over 50 of them and they get their data...
2
by: Peter | last post by:
C# .NET 2.0 - Crystal Reports XI I am trying to connect Crystal Report to DB2 database from my C# application. After I run the connection info code and try to export the report I get ...
0
by: Swaroop Bhattacharyya | last post by:
I want to access IBM DB2 CLP from Crystal Reports.This is for schedueling a job in Crystal Reports. How will i link the Crystal Reports and the IBM DB2 CLP ?
1
by: mahesh123 | last post by:
Hi Folks, I am using the crystal reports 8.0 with VB6.0 and database is MSAccess. When i am connecting to the database through DAO, then i am getting an error DAO.Workspace Not a Valid...
7
by: Mohammed Seidu | last post by:
Hi all, Can anyone help me on how to create crystal reports in a .net windows application? The problem is, i have an OleDbConnection object named 'conn' which I create dynamically to connect to...
3
by: Miro | last post by:
Hi, Just wondering what a good book is on visual studios 2008 ( or 2005 if no 2008 ) that teaches you how to properly use crystal reports with it. Or im assuming that as long as I can create a...
1
by: =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= | last post by:
On reflection, you could possibly make the app a self extracting zip file which extracts the EXE and a settings file and then starts the app, then when you app closes, it can repack the settings...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.