How do I save an Integer type (not int) into Database?
-
1Whats the issue? Autoboxing happens in Java so what different does it make?Subir Kumar Sao– Subir Kumar Sao2012-06-12 07:28:12 +00:00Commented Jun 12, 2012 at 7:28
-
2@subirkumarsao Maybe the issue is with the null value?Boris Strandjev– Boris Strandjev2012-06-12 07:30:14 +00:00Commented Jun 12, 2012 at 7:30
-
Im new to database. Im using 'Integer' and 'Number' type. If I rmmber correctly, I'd have to specify the table column what is the type of data that it will hold, am I right?Fadhlie Ikram– Fadhlie Ikram2012-06-12 07:39:44 +00:00Commented Jun 12, 2012 at 7:39
Add a comment
|
4 Answers
Depending on your database system (mysql, postgre, ...), the integer type will or won't exist in your database. It is then better to use java Integer functions to make an Integer from your database value, which will probably be int or even bigint, depending on what's needed.
As I said in my comment, something like Integer myinteger = new Integer(yourdatabasevalue) should work fine.
2 Comments
Fadhlie Ikram
Im using sqlite, as embedded database.
Gabriel Theron
I don't know sqlite very well, but from what I can see of the docs, it only has the integer type. Then you can store it as Integer in sqlite and make an Integer in java like
Integer myinteger = new Integer(here you retrieve your value) (don't really do the request in there though ^^ this is just an example)