login about faq

I am using MySQL as my database system. I have one field on the table which has a data type of int(65,0).

Upon data retrieval on the java code using prepared statement, I am having loss of data (using the usual getXXXX() method). I have also tried BigDecimal as data type.

What could be the best data type to accommodate big number such as this: 21165471430000012335407429034439500044? With a maximum length of 65?

Thanks ;)

asked Dec 02 '11 at 17:05

Cris's gravatar image

Cris
1718

2

I would've thought that BigDecimal would work. What happens when you use BigDecimal?

(Dec 02 '11 at 21:14) Alistair A. Israel Alistair%20A.%20Israel's gravatar image

In this case, the value on the database is 21165471430000012335407429034439500044

But when fetched through the result set:

nextOID = result.getBigDecimal("uid_maxid");

I am getting a value of -2147483646

(Dec 05 '11 at 12:41) Cris Cris's gravatar image
3

Just to be sure, do you mean "int(65, 0)" or "numeric(65, 0)" in your column definition?

(Dec 05 '11 at 18:44) Bryan Bibat Bryan%20Bibat's gravatar image

Yes, it was designed as int(65, 0). But I also figured out that I should use numeric(65, 0) on the database field instead, for it to match with BigDecimal data type on the code.

Thanks everyone for answering! :)

(Dec 06 '11 at 08:28) Cris Cris's gravatar image

Just to copy the solution above, the problem arose when OP used INT(65,0) instead of NUMERIC(65,0).

This is because the parameter in INT is used only for display width (i.e. practically useless) while the parameters in NUMERIC/DECIMAL define precision and scale.

link

answered Dec 06 '11 at 17:10

Bryan%20Bibat's gravatar image

Bryan Bibat
2.6k119

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×63
×20

Asked: Dec 02 '11 at 17:05

Seen: 556 times

Last updated: Dec 06 '11 at 17:10