I guess answers to your questions are here : 
https://issues.apache.org/jira/browse/DERBY-5151 


Le 26 février 2012 09:45, Karl Weber <karl.weber99@googlemail.com> a écrit :
I have created a sequence using

CREATE SEQUENCE GPS.SDSID
       AS INTEGER
       START WITH 1
       INCREMENT BY 1
       NO CYCLE;

and get values using

NEXT VALUE FOR GPS.SDSID

in separate SELECT statements with jdbc. The corresponding connection has
autocommit = true.

As long as derby is running I get successive numbers, but when derby is shut
down in between I get gaps. Those gaps are quite bad.

Is this a bug or a feature, i.e. is derby buffering about five sequence
numbers in memory (for, e.g., performance reasons), which are lost if derby is
shut down? Is there a way to prohibit losing numbers?