This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am using MySql 5.1. I created a column in table 'phonenumber' with datatype 'int' of length 15. If I enter 9 digit number it is accepting. But if I enter a value directly in the database, it is entering a value '2147483647'.
If I enter details through insert query in my java code, I am getting the following error:
When asked to store a value in a numeric column that is outside the data type's permissible range, MySQL's behavior depends on the SQL mode in effect at the time. For example, if no restrictive modes are enabled, MySQL clips the value to the appropriate endpoint of the range and stores the resulting value instead. However, if strict SQL mode is enabled, MySQL rejects a value that is out of range with an error, and the insert fails, in accordance with the SQL standard.
INT (uses 4 byte, i.e. 32 bits) is probably not enough for your phone number's range (up to 2147483647 as previously written)
With UNSIGNED INT your max number could be 4294967295
If it's not enough, though i imagine it is, MySql allows you to use BIGINT datatype. You can store numbers up to 9223372036854775807 (in the signed version)