2006年7月26日

          • addDay(Date aDate, int iDay) : Date
          • addMonth(Date aDate, int iMonth) : Date
          • addQuarter(Date aDate, int iQuarter) : Date
          • addWeek(Date aDate, int iWeek) : Date
          • addYear(Date aDate, int iYear) : Date
          • getDayOfMonth(Date aDate) : int
          • getDayOfWeek(Date aDate) : int
          • getDayOfYear(Date aDate) : int
          • getDaysBt(Date dFrom, Date dTo) : int
          • getFirstDayOfMonth(Date aDate) : Date
          • getFirstDayOfQuarter(Date aDate) : Date
          • getFirstDayOfWeek(Date aDate) : Date
          • getFirstDayOfYear(Date aDate) : Date
          • getLastDayOfMonth(Date aDate) : Date
          • getLastDayOfQuarter(Date aDate) : Date
          • getLastDayOfWeek(Date aDate) : Date
          • getLastDayOfYear(Date aDate) : Date
          • getMonth(Date aDate) : int
          • getQuarter(Date aDate) : int
          • getYear(Date aDate) : int
          • main(String[] args) : void
          • trunc(Date aDate, String aFormat) : Date
          posted @ 2008-01-29 09:53 BlogCY 閱讀(287) | 評論 (0)編輯 收藏
           

          公司經常更換框架,好不容易寫好的業務模型經常要推倒重來。
          為此考慮將業務模型獨立出來,不受框架的影響。
          具體考慮如下:
          1.接口定義
          DBConnection.java
          public interface DBConnection {
          ? PreparedStatement prepareStatement(String aSql);
          ?....
          ? void free();
          ? void commit();
          ? void rollback();
          }
          DBContext.java
          public interface DBContext {
          ? DBConnection newDBConnection();
          }
          2.模型實現
          public class ActualFlow {
          ? DBContext dbContext=null;
          ? public ActualFlow() {
          ? }
          ? public void init(DBContext aContext){
          ??? dbContext=aContext;
          ? }
          ? public int calculate(String aBranchId,String aYear,String aMonth,String aUserId){
          ??? int iRtn=-1
          ??? PreparedStatement objState=null;
          ??? ResultSet objSet=null;
          ??? DBConnection objCon=null;
          ??? try {
          ????? objCon=dbContext.newDBConnection();
          ????? objState=objCon.prepareStatement("具體的sql語句");
          ????? //業務模型操作......

          ??? }
          ??? catch (Exception ex) {
          ????? ex.printStackTrace();
          ????? iRtn=-1;
          ??? }finally{
          ????? if (objSet!=null) {
          ??????? try {
          ????????? objSet.close();//關閉結果集合
          ??????? }
          ??????? catch (Exception ex) {
          ????????? ex.printStackTrace();
          ??????? }
          ????? }
          ????? if (objState!=null) {
          ??????? try {
          ????????? objState.close();//關閉statement
          ??????? }
          ??????? catch (Exception ex1) {
          ????????? ex1.printStackTrace();
          ??????? }
          ????? }
          ????? if (objCon!=null) {
          ??????? objCon.free();//釋放連接
          ????? }
          ??? }
          ??? return iRtn;
          ? }
          }
          3.在具體的開發框架下面
          ?? 定義EAPDBContext 實現 DBContext
          ???如下方式復用模型:
          ????? ActualFlow objActualFlow=new ActualFlow();
          ? ??? objActualFlow.init(new EAPDBContext("actualFlow"));
          ????? int i=objActualFlow.calculate(this.m_branchID,this.m_year,this.m_month);

          不知道是否合理,先練習練習

          posted @ 2006-08-04 12:52 BlogCY 閱讀(629) | 評論 (0)編輯 收藏
           
          //字符串的Iterator函數
          //例子:
          //var it=new StringIterator("a,b,c,d",",");
          //while(it.hasNext()){
          //? alert(it.next());
          //}
          ?1function?StringIterator(aStr,aSep){
          ?2??this.origin=aStr;
          ?3??this.sep=aSep;
          ?4??this.remain=aStr;
          ?5??this.nextStr=null;
          ?6??this.hasNext=hasNext;
          ?7??function?hasNext()?{
          ?8???var?iIndex=0;
          ?9???if(this.remain==null){this.remain='';}
          10???if(this.remain==''){
          11?????this.nextStr=null;
          12?????return?false;
          13???}

          14???iIndex=this.remain.indexOf(aSep);
          15???if(iIndex<0){
          16?????this.nextStr=this.remain;
          17?????this.remain='';
          18???}
          else{
          19?????this.nextStr=this.remain.substring(0,iIndex);
          20?????this.remain=this.remain.substring(iIndex+this.sep.length);
          21???}

          22???return?true;
          23??}

          24??this.next=next;
          25??function?next()?{
          26???var?strRtn=this.nextStr;
          27???this.nextStr=null;
          28???return?strRtn;
          29??}

          30}

          31
          posted @ 2006-07-29 10:11 BlogCY 閱讀(594) | 評論 (0)編輯 收藏
           
          1.在web.xml中配置
          ? <servlet>
          ??? <servlet-name>excel</servlet-name>
          ??? <servlet-class>××××</servlet-class>
          ? </servlet>
          ? <servlet-mapping>
          ??? <servlet-name>excel</servlet-name>
          ??? <url-pattern>*.xls</url-pattern>
          ? </servlet-mapping>
          2.頁面代碼
          <a title='Excel' id=aa href='/fmudemo/Export.xls?para1=7&para2=1267&para3=null&para4=*'>
          ????? <font size=2>Excel</font>
          </a>
          3.編寫servlet
          ?? 輸出html字符串,
          效果:
          ? 點擊鏈接后,會彈出對話框提示用excel打開。
          posted @ 2006-07-26 13:46 BlogCY 閱讀(606) | 評論 (0)編輯 收藏
           
          主站蜘蛛池模板: 南阳市| 庆城县| 额敏县| 勐海县| 滕州市| 肥乡县| 柳州市| 红桥区| 桦川县| 常德市| 定安县| 简阳市| 安仁县| 忻城县| 商水县| 武陟县| 大新县| 宜黄县| 涟水县| 卓尼县| 南投市| 防城港市| 岱山县| 育儿| 包头市| 永登县| 嘉祥县| 江口县| 磐石市| 九龙城区| 许昌市| 黔西县| 沙湾县| 高碑店市| 邻水| 白银市| 晋城| 当涂县| 杭锦后旗| 洛阳市| 渭南市|