I am using MySQL with Spring JDBC template for my web application. I need to store phone number with only digits (10). I am little bit confused about data type using data type.
Strings & VARCHAR.
Do not try storing phone numbers as actual numbers. it will ruin the formatting, remove preceding 0
s and other undesirable things.
You may, if you choose to, restrict user inputs to just numeric values but even in that case, keep your backing persisted data as characters/strings and not numbers.
Be aware of the wider world and how their number lengths and formatting differ before you try to implement any sort of length restrictions, validations or masks (eg XXX-XXXX-XX).
Non numeric characters can be valid in phone numbers. A prime example being +
as a replacement for 00
at the start of an international number.
Edited in from conversation in comments: