views:

26

answers:

1

Hi there,

I am using SQLite in Java code through Zentus.

I need 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 ?

+1  A: 

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.

MPelletier
Thanks for the answer. This means I can create my table with Type "LONGFOOBAR" for example and the result will be the same ? As mentioned I think there is no problem at SQLite level, but in the JDBC driver I am using. Do you use SQLite from Java code ?
Manuel Selva
No, I use SQLite, but with different code, so that's why I can't give you a 100% enlightened answer. As for type "LONGFOOBAR", it would default internally to "TEXT, but so would "LONG". Only if the type has the letters "INT" the column be declared as INTEGER. Inserting integers will make a TEXT column keep them as ... well, I don't know what. But for your connector, prefer declaring as INTEGER.
MPelletier
Thanks again. I read SQLite typing info, and I know now, thanks to you, how it works and I would modify my types to have INTEGER columns for numerical values. Even knowing and modifying that, I still have my issue and think that there is a problem in the Zentus JDBC driver I am using. I'am investigating ...
Manuel Selva
That is as far as I can help. Sorry.
MPelletier