public static void runReport(String moduleId, HashMap<String, Object> parameterValues, String sql,PreparedStatement preparedstatement, String printQueue)
{
ResultSet resultset;
Statement statement;
JRResultSetDataSource jasperresultset;
JasperPrint jasperPrint = new JasperPrint();
Connection connection;
JInternalFrameReportViewer reportviewer;
Icon reportIcon;
JRPrintServiceExporter exporter;
PrintServiceAttributeSet serviceAttributeSet;
String reportFilename = "";
mod.setModuleId(moduleId);
if (mod.getModuleProperties() == true)
{
reportFilename = Common.report_path + JUtility.removeExtensionFromFilename(mod.getReportFilename(), ".jrxml") + ".jasper";
if (parameterValues==null)
{
parameterValues = new HashMap<String, Object>();
}
parameterValues.putAll(stdparams);
printQueue = JUtility.replaceNullStringwithBlank(printQueue);
if (printQueue.equals(""))
{
printQueue = JPrint.getDefaultPrinterQueueName();
}
else
{
if (JPrint.getDefaultPrinterQueueName().equals(printQueue) == false)
{
JPrint.setPreferredPrinterQueueName(printQueue);
}
}
try
{
//jasperReport = (JasperReport) JRLoader.loadObjectFromLocation(Common.report_path + JUtility.removeExtensionFromFilename(mod.getReportFilename(), ".jrxml")+ ".jasper");
//jasperReport = (JasperReport) RepositoryUtil.getReport(Common.report_path + JUtility.removeExtensionFromFilename(mod.getReportFilename(), ".jrxml")+ ".jasper");
connection = Common.hostList.getHost(Common.selectedHostID).getConnection(Common.sessionID);
sql = JUtility.replaceNullStringwithBlank(sql);
if (sql.isEmpty())
{
if (preparedstatement==null)
{
parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, connection);
}
else
{
resultset = preparedstatement.executeQuery();
jasperresultset = new JRResultSetDataSource(resultset);
parameterValues.put(JRParameter.REPORT_DATA_SOURCE, jasperresultset);
parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, jasperresultset);
}
}
else
{
statement = Common.hostList.getHost(Common.selectedHostID).getConnection(Common.sessionID).createStatement();
statement.setFetchSize(1);
resultset = statement.executeQuery(sql);
jasperresultset = new JRResultSetDataSource(resultset);
parameterValues.put(JRParameter.REPORT_DATA_SOURCE, jasperresultset);
parameterValues.put(JRParameter.REPORT_CONNECTION, connection);
jasperPrint = JasperFillManager.fillReport(reportFilename, parameterValues, jasperresultset);
}