iReport 報表在應用程序中的應用代碼(轉載)

          import dori.jasper.engine.*;
          import dori.jasper.engine.util.*;
          import java.sql.*;
          import java.util.*;
          import dori.jasper.engine.JasperReport;
          import java.util.Date;
          import java.text.SimpleDateFormat;
          import dori.jasper.view.*;
          import org.apache.commons.logging.LogFactory;
          import com.lowagie.text.DocumentException;
          import com.lowagie.text.*;
          import dori.jasper.engine.design.*;
          import org.apache.commons.digester.Digester;
          import org.apache.commons.beanutils.BeanUtils;

          public class myreport
          {
           public void reportName(String strBbmc)
           {
            JRResultSetDataSource jrds = null;
            JasperPrint jasperPrint = null;
            Map reportParams = new HashMap();
            ResultSet rs = null;
            Connection con = null;
            Statement stmt = null;
            String sql = "select * from  bbmc";
            try
             {
              //動態獲取
              JasperDesign jasperDesign = JasperManager.loadXmlDesign("./bbmc.jrxml");
              JasperReport jasperreport = JasperManager.compileReport(jasperDesign);
              //建立連接
              ConnectionpoolManager mgr = new ConnectionpoolManager();
              mgr.setMonitorThread(520);
              mgr.addAlias("jdbcConnecpool","com.microsoft.jdbc.sqlserver.SQLServerDriver","jdbc:microsoft:sqlserver://192.168.45.233:1433;DatabaseName = ysgl ","sa","sa",10,300,520,30,false);
              con = DriverManager.getConnection(ConnectionPoolManager.URL_PREFIX+ConnectionPoolManager.getPoolName(),null,null);
              stmt = con.creatStatement();
              rs = stmt.executeQuery(sql);
              jrds = new JRResultSetDataSource(rs);
              jasperPrint = JasperFillManager.fillReport(jasperReport,reportParams,jrds);
              //調出JasperViewer進行打印預覽
              JasperViewer.viewReport(jasperPrint);
             }
             catch(ClassNotFoundException ee)
              {
               ee.printStackTrace();
              }
             catch(SQLException ex)
              {
               ex.pritStackTrace;
              }
             catch(JRException e)
              {
               e.getMessage();
              }
           }
          }

          posted on 2008-01-08 20:08 靈! 閱讀(279) 評論(0)  編輯  收藏 所屬分類: Java技術-報表


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          <2008年1月>
          303112345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          導航

          統計

          隨筆分類

          隨筆檔案

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 伊春市| 栾川县| 略阳县| 安国市| 南部县| 兴业县| 来宾市| 邓州市| 镇安县| 灵宝市| 海宁市| 卢湾区| 江孜县| 鸡东县| 定边县| 营口市| 会泽县| 讷河市| 六盘水市| 蛟河市| 昭苏县| 佳木斯市| 石泉县| SHOW| 东宁县| 宜阳县| 天峨县| 云阳县| 陇南市| 图片| 孟村| 石屏县| 青铜峡市| 嘉荫县| 图们市| 怀远县| 西乌| 张掖市| 天峻县| 南城县| 北宁市|