在derby中重新连接时,序列的当前值前进到下一个100 [英] Sequence's current value advances to next 100 upon reconnection in derby

查看:148
本文介绍了在derby中重新连接时,序列的当前值前进到下一个100的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对嵌入式数据库的德比序列有疑问.当我第一次连接到数据库时,它会通过以下语句为我提供正确的序列下一个值.

I am having an issue with derby sequences with embedded database. When I first connect to the data base it gives me the correct sequence next value with the following statement.

VALUES (NEXT VALUE FOR :seqNm)

但是,当重新启动我的桌面应用程序时,通过重新连接到数据库,下一个值将为我提供下一个百分数值.似乎derby使用一些缓存来预分配序列号.

But when restart my desktop application, there by reconnecting to the database, the next value gives me the next hundredth value. It seems like derby uses some caching for preallocating the sequence numbers.

例如如果我的序列以100开头, 第一次连接到数据库后,我得到的序列为100、101、102,依此类推.

e.g. if my sequence starts with 100, First connection to the data base gives me sequences as 100, 101, 102 and so on.

与数据库的第二次连接为我提供了200、201、202、203等序列.

Second connection to the data base gives me sequences as 200, 201, 202, 203 and so on.

与数据库的第三次连接为我提供了300、301、302、303等序列.

Third connection to the data base gives me sequences as 300, 301, 302, 303 and so on.

此问题是否有任何解决方法?我正在使用spring连接到数据库.

Is there any workaround for this issue? I am using spring to connect to the database.

谢谢!

推荐答案

根据

According to https://db.apache.org/derby/docs/10.9/ref/rrefproperpreallocator.html, yes there is a sequence preallocator:)

在配置中,只需输入:

derby.language.sequence.preallocator=number

其中number是序列的预分配数量,或

where number is a prealocated number of sequences OR

derby.language.sequence.preallocator=className

其中className导致实现 SequencePreallocator 如果您需要一些更高级的序列分配...

where className leads to a class implementing SequencePreallocator if you want some more advanced sequence alocation...

希望有帮助!

这篇关于在derby中重新连接时,序列的当前值前进到下一个100的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆