MyBatis Skill 獲取資料庫自增id

2021-09-11 01:59:46 字數 413 閱讀 2528

insert標籤中加上

usegeneratedkeys=「true」 keyproperty=「id」

會將id組裝到返回物件中而不是作為返回值

獲取id方法,返回值i並不是id而是影響行數,getid才是資料庫自增的id

int i=userservice.insertselective(record);

system.out.println(i);

system.out.println(record.getid());

讓返回值為資料庫id

加入insert標籤中

select last_insert_id() as id    

獲取隨機數

c 中提供了隨機數函式rand 但是這個函式其實提供的數字是有限的,大概是0 32767,所以這就導致了兩個問題 1 獲取的的數字並不是隨機的,比如要取0 99的隨機數,那麼一般就是rand 100,由於32767 100 67,所以0 67的數字獲得到的次數會比68 99多一次。2 無法獲取到比3...

獲取硬碟總容量,柱面數,磁軌數,扇區數

下面的 來自msdn include include include bool getdrivegeometry disk geometry pdg bresult deviceiocontrol hdevice,device we are querying ioctl disk get drive...

php 獲取隨機數

獲得最小和最大值之間隨機數,位數不足補零 function getrandnumber fmin fmax fileid date ymd his rand 100,999 fileid為 20100903 132121 908 這樣的的隨機數 function randomkeys length ...