在新增一个业务时,在JSP页面上自动生成一个有序的序号

来源:百度知道 编辑:UC知道 时间:2024/05/04 10:32:46
<td width="135"><input name="bgd" type="text" size="18" ></td>
比如在这里input里面自动生成一个有序的序号
比如2009XZYW0001,下次在新增时就是2009XZYW0002以此类推。

帮忙写出来,谢谢!

我一般是用数据库实现自增长序列的,在数据库中插入一条记录包括id字段和初值字段,每次显示时从DB取初值字段的值并update+1

<%@ page import="java.text.*" %>
<%
String time = "";
SimpleDateFormat dformat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
time = dformat.format(new java.util.Date());
time = time.replaceAll("-","");
time = time.replaceAll(" ","");
time = time.substring(0,4);
String ReportType=request.getParameter("ReportType");
Statement stmt = null;
ResultSet rs = null;
Connection conn = null;
SQLBean_JDBC so = new SQLBean_JDBC();
String stringSql="";
String serial4="";
stringSql = "select max(convert(int,substring(yewubaogaodanhao,9,4)))+1 as yewubaogaodanhao "
+" from tuoyun where substring(yewubaogaodanhao,1,4)='"+time+"'";

String serial= "";

t