myeclipse java后台往数据库传参数的ID序号问题
数据库表的ID若是设为自动增长,有时候不好控制,当需要ID做外键的时候就没法弄了,所以手动设置Id序号,便于操作数据。后台Java代码如下:
int NewFormID = 0;
ResultSet rs = null;
String strsql = "select top 1 NewFormID from tAMCustomForm order by NewFormID desc";
try {
rs = stmt.executeQuery(strsql);
} catch (SQLException e) {
logger.debug(e.getMessage());
}
System.out.println("strsql:"+strsql);
try {
while (rs.next()) {
NewFormID=rs.getInt("NewFormID");
}
} catch (SQLException e) {
e.printStackTrace();
}
NewFormID=NewFormID+1;
System.out.println("insertsql = " + strsql);