“out of range” error inserting mobile number from servlet to SQL


April 2019


21 time


I am trying to insert mobile number through prepared satement, but I am getting an error stating that type out of range even for Double type.

pstmt.setDouble(6, 9677627718);

How to insert mobile number from servlet to sql?

It says that out of range even for double data.

1 answers


"Telephone numbers" are not really numbers in the mathematical sense. They are just addresses (similar to email addresses) that happen to be composed of numeric digits. They do not need to be represented as numbers because typical numeric manipulations are not relevant. For example, it makes no sense to subtract one phone number from another.

Therefore you should store telephone numbers in your tables as strings, not as numbers. In particular, a common int (signed, 32-bit) could store the phone number 202-555-1212 (2025551212 with the hyphens removed) but could not store 613-555-1212 because 6135551212 is too large to fit into an int column. (The largest "number" it could hold would be 214-748-3647.)