问题描述
我将数据库用作postgresql,并通过spring jdbctemplate连接到数据库。
数据库中的电话专栏为history and location
春天来了phone bigint
java.lang.NumberFormatException
我的豆是:-
public UserDetails getUserDetails(int phone) {
String sql = "SELECT * FROM users where phone = ?";
UserDetails users = (UserDetails) jdbcTemplate.query(sql,new Object[]{phone},new BeanPropertyRowMapper<UserDetails>(UserDetails.class));
return users;
}
**Error:-**
> For input string: "7894561230"; nested exception is
> java.lang.NumberFormatException: For input string: "7894561230"
解决方法
您的问题出在int
上。
在Java中,int
可以容纳从-2147483648
到2147483647
的任何整数,并且您的值7894561230
超出了它的范围。因此,请使用long
代替int
。