数据库表中MAX ID获取,确保每次调用没有重复工具类(NumberUtil)

2022-11-04,,,,

下面这个类是获取数据库中一个字段的最大值。配置在数据库中。

public class NoFactory {
private final static Logger cLogger = Logger.getLogger(NoFactory.class); protected static final byte cClusterId = 0;
protected static final byte cClusterCount = 1;
private static final byte[] BLCTRANNOId = new byte[0];
private static int BLCTRANNO;
static {
try { BLCTRANNO = Integer.parseInt(new ExeSQL().getOneValue("select max(to_number(BLCTRANNO)) from edorrenewalbalanceacc where mod(BLCTRANNO,"+cClusterCount+")="+cClusterId)); } catch (Throwable ex) {
cLogger.error("初始化最大号异常!", ex);
}
}
public final static int nextBLCTRANNONo() {
synchronized (BLCTRANNOId) {
BLCTRANNO += cClusterCount;
}
return BLCTRANNO;
} public final static void setBLCTRANNONo(int pMaxNo) {
synchronized (BLCTRANNOId) {
BLCTRANNO = pMaxNo - pMaxNo%cClusterCount + cClusterId;
}
} }

  

数据库表中MAX ID获取,确保每次调用没有重复工具类(NumberUtil)的相关教程结束。

《数据库表中MAX ID获取,确保每次调用没有重复工具类(NumberUtil).doc》

下载本文的Word格式文档,以方便收藏与打印。