你的自动加一怎么实现的?
是不是有个表存放maxid,每次取出加一,code = "ts"+ (maxid+1),然后存入加一后的值?
如果是这样,你可以
取出这个maxid
String newCode = "aaa";
for ( int i=1; i<maxid; i++ ) {
String code = "ts" + i;
sqlString = "select code from tableName where code ='" + code + "'";
rs = statement.execteSql(sqlString);
if ( rs.next() ) {
//pass
} else {
newCode = "ts" + i;
break;
}
}
if ( newCode.equals("aaa") ) {
newCode="ts" + (maxid+1);
}这也太麻烦了!
是不是有个表存放maxid,每次取出加一,code = "ts"+ (maxid+1),然后存入加一后的值?
如果是这样,你可以
取出这个maxid
String newCode = "aaa";
for ( int i=1; i<maxid; i++ ) {
String code = "ts" + i;
sqlString = "select code from tableName where code ='" + code + "'";
rs = statement.execteSql(sqlString);
if ( rs.next() ) {
//pass
} else {
newCode = "ts" + i;
break;
}
}
if ( newCode.equals("aaa") ) {
newCode="ts" + (maxid+1);
}这也太麻烦了!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货