81,092
社区成员
发帖
与我相关
我的任务
分享
CREATE TABLE `user` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(16) NOT NULL,
`phone` varchar(11) NOT NULL,
`sex` int(11) NOT NULL DEFAULT '-1',
`role` int(11) DEFAULT '0' ,
`passwd` varchar(32) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
public class User {
private Integer userId;
private String userName;
private String userPassword;
private String userPhone;
private Integer userSex;
private Integer userRole;
……
}
2018-05-07 15:55:59.177 DEBUG 12912 --- [nio-8080-exec-5] c.s.dinner.mapper.UserMapper.createUser : ==> Preparing: insert into user(name,passwd, phone,sex)values(?,?,?,?)
2018-05-07 15:55:59.177 DEBUG 12912 --- [nio-8080-exec-5] c.s.dinner.mapper.UserMapper.createUser : ==> Parameters: 'test'(String), '123456'(String), '18516693703'(String), 1(Integer)
2018-05-07 15:55:59.193 ERROR 12912 --- [nio-8080-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException:
### Error updating database. Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'phone' at row 1
### The error may involve com.senxiang.dinner.mapper.UserMapper.createUser-Inline
### The error occurred while setting parameters
### SQL: insert into user(name,passwd, phone,sex)values(?,?,?,?)
### Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'phone' at row 1
; ]; Data truncation: Data too long for column 'phone' at row 1; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'phone' at row 1] with root cause