File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to call 3 jasper report subreport in java code

 
singh Mari
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using jasper report and 3-subreports. but i cannot call subreport in java code and the following error can occur,


"The supplied java.sql.connection object is null"
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm no Jasper expert, but how are you supplying the connection?
 
singh Mari
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/sims1", "root", "opel");
Statement stmt = (Statement) con.createStatement();
//ResultSet rs=stmt.executeQuery("select student_id ,student_name,student_date_of_birth FROM student where student_coursename='"+program_name+"'and student_scheme='"+scheme+"'and student_term='"+term+"'");
ResultSet rs = stmt.executeQuery("select * from studentterm where attempt='1'");
JRResultSetDataSource dataSource = new JRResultSetDataSource(rs);
JasperReport jasperReport = JasperCompileManager.compileReport("C://SIMS/web/studentterm1.jrxml");
JasperPrint jprint = JasperFillManager.fillReport(jasperReport, new HashMap(), dataSource);
JasperViewer jasViewer = new JasperViewer(jprint, false);
jasViewer.setVisible(true);
jasViewer.toFront()
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which line is throwing the exception? Do you have a full stack trace? Also check the datasource before you pass it to Jasper, is it null in your code for some reason?
 
me bala
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Singh marrie,
Even i want to run the jasper report with the sub report using java files.
If you know that means please share your knowledge.......

I need that..

Thanks in advance...
mebala
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic