首页上一页 1 下一页尾页 1 条记录 1/1页
《java从入门到精通》第二十八章
发表在Java图书答疑
2010-10-15
是否精华
是
否
版块置顶:
是
否
我买的书是第一版,在该书的28章进销存管理系统中的类Dao中有这样一个方法
// 获取更类主表最大ID
private static String getMainTypeTableMaxId(Date date, String table,
String idChar, String idName) {
String dateStr = date.toString().replace("-", "");
String id = idChar + dateStr;
String sql = "select max(" + idName + ") from " + table + " where "
+ idName + " like '" + id + "%'";
ResultSet set = query(sql);
String baseId = null;
try {
if (set.next())
baseId = set.getString(1);
} catch (SQLException e) {
e.printStackTrace();
}
baseId = baseId == null ? "000" : baseId.substring(baseId.length() - 3);
int idNum = Integer.parseInt(baseId) + 1;
id += String.format("%03d", idNum);
return id;
}
请教一下
baseId = baseId == null ? "000" : baseId.substring(baseId.length() - 3);
int idNum = Integer.parseInt(baseId) + 1;
id += String.format("%03d", idNum);
return id;
是什么意思。
// 获取更类主表最大ID
private static String getMainTypeTableMaxId(Date date, String table,
String idChar, String idName) {
String dateStr = date.toString().replace("-", "");
String id = idChar + dateStr;
String sql = "select max(" + idName + ") from " + table + " where "
+ idName + " like '" + id + "%'";
ResultSet set = query(sql);
String baseId = null;
try {
if (set.next())
baseId = set.getString(1);
} catch (SQLException e) {
e.printStackTrace();
}
baseId = baseId == null ? "000" : baseId.substring(baseId.length() - 3);
int idNum = Integer.parseInt(baseId) + 1;
id += String.format("%03d", idNum);
return id;
}
请教一下
baseId = baseId == null ? "000" : baseId.substring(baseId.length() - 3);
int idNum = Integer.parseInt(baseId) + 1;
id += String.format("%03d", idNum);
return id;
是什么意思。