写一个.properties文件就好了
一个property记录日期,即20041205
一个property记录编号,即02然后写个小程序,判断当前日期和记录日期是否一致,如果一致就将记录编号加1,如果不一致,则将记录编号返回01。然后将记录日期和记录编号字符串连接一下输出就搞定!

解决方案 »

  1.   

    这个实现就要先查询数据库,当天的话就在上一个基础上+1,不是当天的就重新开始计,这个编号你可以设置为string类型和int类型的转换,
    number= xxxxx; //get from the data base(string )
    number=Integer.parseInt)number.subString(11))+1;rightnow=new GregorianCalendar()
    SimpleDateFormat pattern = new SimpleDateFormat("yyyyMMdd");
    String time=pattern.format(this.rightnow.getTime());
    String modelnumber="com"+time+number;
      

  2.   

    select max[id] as maxid from [dbname] 得到最大的编号maxid
    if(!maxid.subString(0,10).equals("com"+(new Date().getYear+1900)+(new Date().getMonth()+1)+new Date().getDate())){
    当前id="com"+(new Date().getYear+1900)+(new Date().getMonth()+1)+new Date().getDate()+"01";
    }else{
    当前id="com"+(Long.parseLong(maxid.subString(3,12))+1);
    }
      

  3.   

    上面这句
    id="com"+(new Date().getYear+1900)+(new Date().getMonth()+1)+new Date().getDate()+"01";
    getYear后面少了() 不好意思
      

  4.   

    type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 9 in the jsp file: /add.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\diannao\org\apache\jsp\add_jsp.java:68: cannot resolve symbol
    symbol  : constructor Date ()
    location: class java.sql.Date
    if(!maxid.subString(0,10).equals("com"+(new Date().getYear()+1900)+(new Date().getMonth()+1)+new Date().getDate())){
                                            ^
    An error occurred at line: 9 in the jsp file: /add.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\diannao\org\apache\jsp\add_jsp.java:68: cannot resolve symbol
    symbol  : constructor Date ()
    location: class java.sql.Date
    if(!maxid.subString(0,10).equals("com"+(new Date().getYear()+1900)+(new Date().getMonth()+1)+new Date().getDate())){
                                                                        ^
    An error occurred at line: 9 in the jsp file: /add.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\diannao\org\apache\jsp\add_jsp.java:68: cannot resolve symbol
    symbol  : constructor Date ()
    location: class java.sql.Date
    if(!maxid.subString(0,10).equals("com"+(new Date().getYear()+1900)+(new Date().getMonth()+1)+new Date().getDate())){
                                                                                                 ^
    An error occurred at line: 9 in the jsp file: /add.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\diannao\org\apache\jsp\add_jsp.java:68: cannot resolve symbol
    symbol  : method subString (int,int)
    location: class java.lang.String
    if(!maxid.subString(0,10).equals("com"+(new Date().getYear()+1900)+(new Date().getMonth()+1)+new Date().getDate())){
             ^
    An error occurred at line: 9 in the jsp file: /add.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\diannao\org\apache\jsp\add_jsp.java:69: cannot resolve symbol
    symbol  : constructor Date ()
    location: class java.sql.Date
    bianhao="com"+(new Date().getYear()+1900)+(new Date().getMonth()+1)+new Date().getDate()+"01";
                   ^
    An error occurred at line: 9 in the jsp file: /add.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\diannao\org\apache\jsp\add_jsp.java:69: cannot resolve symbol
    symbol  : constructor Date ()
    location: class java.sql.Date
    bianhao="com"+(new Date().getYear()+1900)+(new Date().getMonth()+1)+new Date().getDate()+"01";
                                               ^
    An error occurred at line: 9 in the jsp file: /add.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\diannao\org\apache\jsp\add_jsp.java:69: cannot resolve symbol
    symbol  : constructor Date ()
    location: class java.sql.Date
    bianhao="com"+(new Date().getYear()+1900)+(new Date().getMonth()+1)+new Date().getDate()+"01";
                                                                        ^
    An error occurred at line: 9 in the jsp file: /add.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\diannao\org\apache\jsp\add_jsp.java:71: cannot resolve symbol
    symbol  : method subString (int,int)
    location: class java.lang.String
    bianhao="com"+(Long.parseLong(maxid.subString(3,12))+1);
                                       ^
    8 errors .service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.0.29 logs.type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 9 in the jsp file: /add.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\diannao\org\apache\jsp\add_jsp.java:68: cannot resolve symbol
    symbol  : constructor Date ()
    location: class java.sql.Date
    if(!maxid.subString(0,10).equals("com"+(new Date().getYear()+1900)+(new Date().getMonth()+1)+new Date().getDate())){
                                            ^
    An error occurred at line: 9 in the jsp file: /add.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\diannao\org\apache\jsp\add_jsp.java:68: cannot resolve symbol
    symbol  : constructor Date ()
    location: class java.sql.Date
    if(!maxid.subString(0,10).equals("com"+(new Date().getYear()+1900)+(new Date().getMonth()+1)+new Date().getDate())){
                                                                        ^
    An error occurred at line: 9 in the jsp file: /add.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\diannao\org\apache\jsp\add_jsp.java:68: cannot resolve symbol
    symbol  : constructor Date ()
    location: class java.sql.Date
    if(!maxid.subString(0,10).equals("com"+(new Date().getYear()+1900)+(new Date().getMonth()+1)+new Date().getDate())){
                                                                                                 ^
    An error occurred at line: 9 in the jsp file: /add.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\diannao\org\apache\jsp\add_jsp.java:68: cannot resolve symbol
    symbol  : method subString (int,int)
    location: class java.lang.String
    if(!maxid.subString(0,10).equals("com"+(new Date().getYear()+1900)+(new Date().getMonth()+1)+new Date().getDate())){
             ^
    An error occurred at line: 9 in the jsp file: /add.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\diannao\org\apache\jsp\add_jsp.java:69: cannot resolve symbol
    symbol  : constructor Date ()
    location: class java.sql.Date
    bianhao="com"+(new Date().getYear()+1900)+(new Date().getMonth()+1)+new Date().getDate()+"01";
                   ^
    An error occurred at line: 9 in the jsp file: /add.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\diannao\org\apache\jsp\add_jsp.java:69: cannot resolve symbol
    symbol  : constructor Date ()
    location: class java.sql.Date
    bianhao="com"+(new Date().getYear()+1900)+(new Date().getMonth()+1)+new Date().getDate()+"01";
                                               ^
    An error occurred at line: 9 in the jsp file: /add.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\diannao\org\apache\jsp\add_jsp.java:69: cannot resolve symbol
    symbol  : constructor Date ()
    location: class java.sql.Date
    bianhao="com"+(new Date().getYear()+1900)+(new Date().getMonth()+1)+new Date().getDate()+"01";
                                                                        ^
    An error occurred at line: 9 in the jsp file: /add.jsp
    Generated servlet error:
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\diannao\org\apache\jsp\add_jsp.java:71: cannot resolve symbol
    symbol  : method subString (int,int)
    location: class java.lang.String
    bianhao="com"+(Long.parseLong(maxid.subString(3,12))+1);
                                       ^
    8 errors
    不好意思,我是新手,刚试过,有问题以上,还请楼上的帮忙解决!有点急!谢谢!!