遇到一个奇怪的错误
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Out of range value for column 'userId' at row 1 com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3374) com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308) com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837) com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961) com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543) com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737) com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2022) com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1940) com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1925) org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
然后追溯到sql语句
insert into t_access_log (access_day, access_daytime, access_type, description, device_id, device_type, extranet_ip, ip, operate_result, os_type, query_string, request_target, requestURI, reserved, session2_id, time, user_agent, userId, username) values ('2016-03-18', '2016-03-18 20:23:03', '1', '手机端视频列表', null, null, '127.0.0.1', '127.0.0.1', '总条数:756', null, null, 'video:json', '/video/json', NULL, 'E065035A48A191F7DA5BA312E0112705', 1458303783, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36', -1, null);
执行结果:
[SQL]insert
into
t_access_log
(access_day, access_daytime, access_type, description, device_id, device_type, extranet_ip,
ip, operate_result, os_type, query_string, request_target, requestURI, reserved, session2_id, time, user_agent, userId, username)
values
('2016-03-18', '2016-03-18 20:23:03', '1', '手机端视频列表', null, null, '127.0.0.1', '127.0.0.1',
'总条数:756', null, null, 'video:json', '/video/json', NULL, 'E065035A48A191F7DA5BA312E0112705', 1458303783,
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36', -1, null);
[Err] 1264 - Out of range value for column 'userId' at row 1
userId的类型是正整数,所以报错了