public class ReportGen{
public JasperPrint generateReport(String custInfo){
Connection conn = null;
JasperPrint myJPrint = null;
// Taking backup of the default classloader
ClassLoader systemClassLoader = Thread.currentThread().getContextClassLoader();
try {
// Loading my custom classloader
// Connecting to the database
conn = ConnectManager.getConnection();
// Loading my jasper file
JasperReport jasperReport = null; Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); String reportPath=ProjectUtil.getRoot(Activator.PLUGIN_ID)+"properties/bug.jasper";
jasperReport=(JasperReport)(JasperReport)JRLoader.loadObjectFromLocation(reportPath);
// Passing parameters to the report
Map parameters = new HashMap();
parameters.put("name", custInfo);
// Filling the report with data from
// the database based on the parameters passed.
myJPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);
// Closing the database connection
conn.close();
}catch(JRException jrExp){
jrExp.printStackTrace();
}catch (SQLException e) {
try {
conn.close();
}catch (SQLException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}catch(Exception dd){
dd.printStackTrace();
}finally{
Thread.currentThread().setContextClassLoader(systemClassLoader);
}
return myJPrint;
}
}
该程序使用了SWTJaserreport.JAR
程序总是在这行运行跳出至finally
myJPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);
没有任何错误提示。
请问这是什么样的错误。
public JasperPrint generateReport(String custInfo){
Connection conn = null;
JasperPrint myJPrint = null;
// Taking backup of the default classloader
ClassLoader systemClassLoader = Thread.currentThread().getContextClassLoader();
try {
// Loading my custom classloader
// Connecting to the database
conn = ConnectManager.getConnection();
// Loading my jasper file
JasperReport jasperReport = null; Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); String reportPath=ProjectUtil.getRoot(Activator.PLUGIN_ID)+"properties/bug.jasper";
jasperReport=(JasperReport)(JasperReport)JRLoader.loadObjectFromLocation(reportPath);
// Passing parameters to the report
Map parameters = new HashMap();
parameters.put("name", custInfo);
// Filling the report with data from
// the database based on the parameters passed.
myJPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);
// Closing the database connection
conn.close();
}catch(JRException jrExp){
jrExp.printStackTrace();
}catch (SQLException e) {
try {
conn.close();
}catch (SQLException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}catch(Exception dd){
dd.printStackTrace();
}finally{
Thread.currentThread().setContextClassLoader(systemClassLoader);
}
return myJPrint;
}
}
该程序使用了SWTJaserreport.JAR
程序总是在这行运行跳出至finally
myJPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);
没有任何错误提示。
请问这是什么样的错误。
里的几个参数都不知道是什么,不好判断,另外,你可以在plugin的rumtime项中添加jar,而不用每次都自己写classloader来加载