Go Back   Velocity Reviews > General Computer Discussion > Software
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
Old 11-11-2006, 07:05 AM   #1
Default how to overcome the nullpointer exception


Hi friends while I try a sample code I found some difficulties.

The sample code is

public class CrystalClient {
private static final String CONNECT_STRING = "DSN=abp";
private static final String REPORT_FILE_NAME = "d:\\arp\\Report1.rpt";
private static final String SQL_QUERY = "select * from student";
private static final String PRINT_FILE = "d:\\arp\\YourNewReport.doc";


public static void main(String args[]) throws Exception{
try {
crystal.CrystalReport report = new crystal.CrystalReport();

//report.aboutBox(); // Lets see if it was loaded properly



report.setConnect(CONNECT_STRING);

report.setReportFileName(REPORT_FILE_NAME);

report.setSQLQuery(SQL_QUERY);

report.setPrinterCopies((short) 1);
report.setPrinterCollation(crystal.PrinterCollatio nConstants.crptDefault);

report.setDestination(crystal.DestinationConstants .crptToFile);
report.setPrintFileName(PRINT_FILE);
report.setPrintFileType(crystal.PrintFileTypeConst ants.crptWinWord); // Change output type if necessary

report.printReport();

}
catch(Exception e)
{
System.out.println(e);
e.printStackTrace();
}
finally {
com.linar.jintegra.Cleaner.releaseAll();
}
}
}

The output of the execution is ....

java.lang.NullPointerException
at crystal.CrystalReport.printReport(CrystalReport.ja va:4482)
java.lang.NullPointerException
at javaapplication10.CrystalClient.main(CrystalClient .java:42)
BUILD SUCCESSFUL (total time: 0 seconds)

How can I overcome this.


arputharaj
arputharaj is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
exception has been thrown by the target of an invocation mintcremes General Help Related Topics 0 07-03-2008 02:51 AM
java.net.SocketException: Broken pipe exception at HttpServletRequest sadasivar Software 0 03-11-2008 04:40 AM
exception unknown software exception error - Excel.exe mfinamore Software 0 11-15-2007 04:54 PM
Exception in thread "main" java.lang.NoClassDefFoundError: prakash.nmsp@gmail.com Software 0 06-29-2007 10:03 AM
Help on PrincipalPermission Demand Throwing Exception Abba Biya MCTS 1 02-07-2007 10:05 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46