开发者

Long type with SQLite and Zentus Jdbc driver

开发者 https://www.devze.com 2023-01-09 03:35 出处:网络
I am using SQLite in Java code through Zentus. I need 开发者_StackOverflow社区to map Java long primitive type in my database. For that I tried to create tables with the following statement: CREATE TA

I am using SQLite in Java code through Zentus.

I need 开发者_StackOverflow社区to map Java long primitive type in my database. For that I tried to create tables with the following statement: CREATE TABLE MY TABLE (...., LONG time, ...).

Insertion into the database through Java with Zentus works perfectly but when retrieving the data, always through Java and Zentus, the LONG value is shrinked to 32 bit value.

I tried to query the database directly with SQlite and it works, thus I guess the problem is the JDBC driver.

Did some of you already experienced such issues, and how did you solved it ?


SQLite has 4 primitive types:

  • Text
  • Integer
  • Real
  • Blob

Some key words are converted to these types, unknown keywords default to Text. The "Integer" type is a bit particular, in that SQLite will only keep the minimum size necessary to record the largest number. If your largest number is smaller than 2^31, it will be recorded on 32 bits. I don't know that it shrinks back if it is expanded to 64 bits then all the values above 2^31 are removed, or if it just stays the same. It will definitely shrink back if the database is vacuumed.

I can suggest keeping a dummy record with a 64 bit value, try and see if JDBC behaves after that.

0

精彩评论

暂无评论...
验证码 换一张
取 消