使用Java在Web上实现简易干特图之五

类别:Java 点击:0 评论:0 推荐:

(表格4)是从数据库获得数据。

PlanManager.java中的部分代码

public Vector getAllPlan() {

        String sql =    "select id,proname, stAllM, endAllM, iAll, startdate, endDate from PlanSc order by id";//获得数据的SQL语句

        Vector vec = new Vector();

        try {

            this.getConnection();

            Statement st = conn.createStatement();

            ResultSet rs = st.executeQuery(sql);

            while (rs.next()) {

                Hashtable hashCar = new Hashtable();

                //获取一条记录

                String id = rs.getString("id");

                String proname =

                    new String(

                        rs.getString("proname").getBytes("ISO-8859-1"),

                        "GBK");

                String stAllM = rs.getString("stAllM");

                String endAllM = rs.getString("endAllM");

                String iAll = rs.getString("iAll");

                String startdate = rs.getString("startdate");

                String endDate = rs.getString("endDate");

                //把一条记录装载到哈希表

                hashCar.put("id", id);

                hashCar.put("proname", proname);

                hashCar.put("stAllM", stAllM);

                hashCar.put("endAllM", endAllM);

                hashCar.put("iAll", iAll);

                hashCar.put("startdate", startdate);

                hashCar.put("endDate", endDate);

                //把哈希表装到Vector变量

                vec.addElement(hashCar);

            }

        } catch (Exception ex) {

        }  finally {

            try {

                if (st != null) {

                    st.close();

                }

                if (conn != null) {

                    conn.close();

                }

                dbconn.CloseConn();

            } catch (SQLException ex) {

                System.out.print("关闭连接错误");

            }

        }

        return vec; // Vector变量返回到调用的JSP

    }

(表格4)

 

(表格5)jindubiao.jsp中的部分代码,把获得数据解开到数组和获得第二类型(调整进度计划)的的数据(与第一类型-规划建设进度同理)

jindubiao.jsp中的部分代码

java.lang.String[][] myall=new java.lang.String [12][7];//声明数组

              java.util.Enumeration enuDrivers = vec.elements();

              int j=0;

              while(enuDrivers.hasMoreElements()){ 

                     java.util.Hashtable hashDriver= (java.util.Hashtable)enuDrivers.nextElement();

                     String id=(java.lang.String)hashDriver.get("id");  

                     String proname=(java.lang.String)hashDriver.get("proname");   

                     String stAllM=(java.lang.String)hashDriver.get("stAllM");

                     String endAllM=(java.lang.String)hashDriver.get("endAllM");    

                     String iAll=(java.lang.String)hashDriver.get("iAll");     

                     String startdate=(java.lang.String)hashDriver.get("startdate");    

                     String endDate=(java.lang.String)hashDriver.get("endDate");

                     myall[j][0]      = id;

                     myall[j][1]      = proname;

                     myall[j][2]      = stAllM;

                     myall[j][3]      = endAllM;

                     myall[j][4]      = iAll;

                     myall[j][5]      = startdate;

                     myall[j][6]      = endDate;     

                     j++;

              }

       

       

//获得第二类型(调整进度计划),注意是getAllPlan2

              Vector vec2 = new Vector();

              vec2 = planC.getAllPlan2();

              java.lang.String[][] myall2=new java.lang.String [12][7];

           java.util.Enumeration enuDrivers2 = vec2.elements();

              int j2=0;

              while(enuDrivers2.hasMoreElements()){

                     java.util.Hashtable hashDriver2= (java.util.Hashtable)enuDrivers2.nextElement();

                     String id=(java.lang.String)hashDriver2.get("id");

                     String proname=(java.lang.String)hashDriver2.get("proname"); 

                     String stAllM=(java.lang.String)hashDriver2.get("stAllM");

                     String endAllM=(java.lang.String)hashDriver2.get("endAllM");  

                     String iAll=(java.lang.String)hashDriver2.get("iAll");   

                     String startdate=(java.lang.String)hashDriver2.get("startdate");  

                     String endDate=(java.lang.String)hashDriver2.get("endDate");

                     myall2[j2][0]   = id;

                     myall2[j2][1]   = proname;

                     myall2[j2][2]   = stAllM;

                     myall2[j2][3]   = endAllM;

                     myall2[j2][4]   = iAll;

                     myall2[j2][5]   = startdate;

                     myall2[j2][6]   = endDate;     

                     j2++;

              }           

(表格5)

本文地址:http://com.8s8s.com/it/it16638.htm