Data truncation: Out of range value

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用系列 2核4GB
简介:

遇到一个奇怪的错误

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语句

Sql代码   收藏代码
  1. insert   
  2.         into  
  3.             t_access_log  
  4.             (access_day, access_daytime, access_type, description, device_id, device_type, extranet_ip,   
  5. ip, operate_result, os_type, query_string, request_target, requestURI, reserved, session2_id, time, user_agent, userId, username)   
  6.         values  
  7.             ('2016-03-18''2016-03-18 20:23:03''1''手机端视频列表'nullnull'127.0.0.1''127.0.0.1',  
  8.  '总条数:756'nullnull'video:json''/video/json'NULL'E065035A48A191F7DA5BA312E0112705', 1458303783,   
  9. '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的类型,终于找到了原因

 

userId的类型是正整数,所以报错了

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
RuntimeError: Given groups=1, weight of size 64 128 1 7, expected input[16,
RuntimeError: Given groups=1, weight of size 64 128 1 7, expected input[16,
2849 0
|
5月前
|
Linux Windows
【已解决】ValueError: num_samples should be a positive integer value, but got num_samples=0
【已解决】ValueError: num_samples should be a positive integer value, but got num_samples=0
成功解决but is 0 and 2 (computed from start 0 and end 9223372 over shape with rank 2 and stride-1)
成功解决but is 0 and 2 (computed from start 0 and end 9223372 over shape with rank 2 and stride-1)
The size of tensor a (4) must match the size of tensor b (3) at non-singletonThe size of
The size of tensor a (4) must match the size of tensor b (3) at non-singletonThe size of
812 0
Expected more than 1 value per channel when training, got input size torch.Size
因为模型中用了batchnomolization,训练中用batch训练的时候当前batch恰好只含一个sample,而由于BatchNorm操作需要多于一个数据计算平均值,因此造成该错误。
856 0
|
JSON 数据格式
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
496 0
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
range
range() 是一个函数,可以用来生成一个自然数的序列。 该函数需要三个参数:起始位置(可以省略,默认是 0);结束位置;步长(可以省略,默认是 1)。 通过 range() 可以创建一个执行指定次数的 for 循环。
103 0
range
|
存储
range_hashed
range_hashed
82 0
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
|
Linux Python
ValueError: empty range for randrange() (0, 0, 0)
ValueError: empty range for randrange() (0, 0, 0)