| 
 private Connection conn = null; 
private Statement st = null; 
private ResultSet rs = null; 
private PreparedStatement pstmt = null; 
public boolean UpdatePlan(int type,String proname,    String stAllM,String endAllM, 
        String iAll,    String startDate,String endDate) { 
        String sql = ""; //可实行的SQL语句 
        this.getConnection();//数据库连接是在另一个地方提供,这里不作详细的描述 
        //type代表不同类型的-选择调整对象 
        if (type = = 1) {//根据不同的选择调整对象构着不同的SQL语句 
            sql = 
                "update PlanSc set stAllM=" 
                    + stAllM 
                    + ",endAllM=" 
                    + endAllM 
                    + ",iAll=" 
                    + iAll 
                    + ",startdate='" 
                    + startDate 
                    + "',endDate='" 
                    + endDate 
                    + "' where proname='" 
                    + proname 
                    + "'"; 
        } else { 
            sql = 
                "update PlanSc2 set stAllM=" 
                    + stAllM 
                    + ",endAllM=" 
                    + endAllM 
                    + ",iAll=" 
                    + iAll 
                    + ",startdate='" 
                    + startDate 
                    + "',endDate='" 
                    + endDate 
                    + "' where proname='" 
                    + proname 
                    + "'"; 
        } 
        boolean f = false; 
        try { 
            st = conn.createStatement(); 
            f = st.execute(sql);//执行SQL语句 
        } catch (Exception ex) { 
            ex.printStackTrace(); 
        }  finally { 
            try { 
                if (st != null) { 
                    st.close(); 
                } 
                if (conn != null) { 
                    conn.close(); 
                } 
                dbconn.CloseConn(); 
            } catch (SQLException ex) { 
                System.out.print("关闭连接错误"); 
            } 
        } 
        return f;//返回执行的情况 
    }  |