首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Tried to send an out-of-range integer as a 2-byte value

Tried to send an out-of-range integer as a 2-byte value

原创
作者头像
二锅头一桶天下
发布于 2024-06-26 03:57:05
发布于 2024-06-26 03:57:05
3180
举报

背景

Cause: org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend.

; An I/O error occurred while sending to the backend.; nested exception is org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend. at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:107) ~[spring-jdbc-5.3.27.jar:5.3.27] at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) ~[spring-jdbc-5.3.27.jar:5.3.27] at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:79) ~[spring-jdbc-5.3.27.jar:5.3.27] at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:79) ~[spring-jdbc-5.3.27.jar:5.3.27] at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:88) ~[mybatis-spring-2.0.4.jar:2.0.4] at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440) ~[mybatis-spring-2.0.4.jar:2.0.4] at com.sun.proxy.$Proxy107.insert(Unknown Source) ~[?:?] at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:271) ~[mybatis-spring-2.0.4.jar:2.0.4] at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62) ~[mybatis-3.5.4.jar:3.5.4] at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:144) ~[mybatis-3.5.4.jar:3.5.4] at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85) ~[mybatis-3.5.4.jar:3.5.4] at com.sun.proxy.$Proxy161.batchInsert(Unknown Source) ~[?:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_301] at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) ~[?:1.8.0_301] at java.util.concurrent.FutureTask.run(FutureTask.java) ~[?:1.8.0_301] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_301] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_301] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_301] Caused by: org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend. at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:349) ~[postgresql-42.2.25.jar:42.2.25] at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:481) ~[postgresql-42.2.25.jar:42.2.25] at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:401) ~[postgresql-42.2.25.jar:42.2.25] at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:164) ~[postgresql-42.2.25.jar:42.2.25] at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:153) ~[postgresql-42.2.25.jar:42.2.25] at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44) ~[HikariCP-4.0.3.jar:?] at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java) ~[HikariCP-4.0.3.jar:?] at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47) ~[mybatis-3.5.4.jar:3.5.4] at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) ~[mybatis-3.5.4.jar:3.5.4] at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) ~[mybatis-3.5.4.jar:3.5.4] at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) ~[mybatis-3.5.4.jar:3.5.4] at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) ~[mybatis-3.5.4.jar:3.5.4] at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197) ~[mybatis-3.5.4.jar:3.5.4] at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184) ~[mybatis-3.5.4.jar:3.5.4] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_301] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_301] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_301] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_301] at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426) ~[mybatis-spring-2.0.4.jar:2.0.4] ... 25 more Caused by: java.io.IOException: Tried to send an out-of-range integer as a 2-byte value: 51765 at org.postgresql.core.PGStream.sendInteger2(PGStream.java:349) ~[postgresql-42.2.25.jar:42.2.25] at org.postgresql.core.v3.QueryExecutorImpl.sendParse(QueryExecutorImpl.java:1559) ~[postgresql-42.2.25.jar:42.2.25] at org.postgresql.core.v3.QueryExecutorImpl.sendOneQuery(QueryExecutorImpl.java:1884) ~[postgresql-42.2.25.jar:42.2.25] at org.postgresql.core.v3.QueryExecutorImpl.sendQuery(QueryExecutorImpl.java:1445) ~[postgresql-42.2.25.jar:42.2.25] at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:314) ~[postgresql-42.2.25.jar:42.2.25] at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:481) ~[postgresql-42.2.25.jar:42.2.25] at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:401) ~[postgresql-42.2.25.jar:42.2.25] at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:164) ~[postgresql-42.2.25.jar:42.2.25] at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:153) ~[postgresql-42.2.25.jar:42.2.25] at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44) ~[HikariCP-4.0.3.jar:?] at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java) ~[HikariCP-4.0.3.jar:?] at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47) ~[mybatis-3.5.4.jar:3.5.4] at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) ~[mybatis-3.5.4.jar:3.5.4] at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) ~[mybatis-3.5.4.jar:3.5.4] at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) ~[mybatis-3.5.4.jar:3.5.4] at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) ~[mybatis-3.5.4.jar:3.5.4] at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197) ~[mybatis-3.5.4.jar:3.5.4] at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184) ~[mybatis-3.5.4.jar:3.5.4] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_301] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_301] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_301] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_301] at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426) ~[mybatis-spring-2.0.4.jar:2.0.4] ... 25 more

分析

2-byte的范围是:-32768~32767

从代码中看到参数为51765,远远超过了short的限制

但是,我的insert参数只有2465个

如何会达到51765个?

从debug中看,pgsql会将所有的pos按照顺序拆开成一个数组,即所有的列都拼在一起:[P0_field1, P0_field2, P1_field1, P1_field2, P2_field1, P2_field2, P3_field1, P3_field2]

po这里有21个field,则21 * 2465 = 51765

所以,还是pos太大了,需要拆分

解决方法

不要一次insert,拆分成多次。

考虑到short.MAXVALUE的值,最大的insert为 32767 / 21 = 1560个

扩展:field字段超过大小,报错形式

刚开始还以为是字段值超过了大小,但是看table中都是int4的,不存在超过大小的情况。

超过大小的报错内容为:

Caused by: org.postgresql.util.PSQLException: ERROR: smallint out of range at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2565) ~[postgresql-42.2.25.jar:42.2.25]

Caused by: org.postgresql.util.PSQLException: ERROR: value too long for type character varying(32) at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2565) ~[postgresql-42.2.25.jar:42.2.25]

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
都说了能不动就别动,非要去调整,出生产事故了吧 → 补充
都说了能不动就别动,非要去调整,出生产事故了吧 中有一个地方讲的有瑕疵,不知道你们发现了没有
青石路
2024/02/27
2820
都说了能不动就别动,非要去调整,出生产事故了吧 → 补充
MysqlDataTruncation: Data truncation: Incorrect string value: '\xF0\x9D\x90\xB6"#...' for column
版权声明:本文为博主原创文章,欢迎转载。 https://blog.csdn.net/chengyuqiang/article/details/89037027
程裕强
2019/07/02
3K0
公司新来一个干练小伙,把 MyBatis 替换成 MyBatis-Plus,上线后哭晕在厕所。。。
一个老项目,数据库用的是 MySQL 5.7.36 , ORM 框架用的 MyBatis 3.5.0 , mysql-connector-java 版本是 5.1.26
搜云库技术团队
2024/05/11
2770
公司新来一个干练小伙,把 MyBatis 替换成 MyBatis-Plus,上线后哭晕在厕所。。。
HTTP Status 500 - Request processing failed; nested exception is org.springframework.jdbc.BadSqlGram
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xmt1139057136/article/details/88684939
业余草
2019/04/09
6.3K0
HTTP Status 500 - Request processing failed; nested exception is org.springframework.jdbc.BadSqlGram
HikariPool-1 - Exception during pool initialization. Springboot 默认选择的mysql问题
samRsa
2025/02/24
2790
一次org.springframework.jdbc.BadSqlGrammarException ### Error querying database Cause: com.mysql.jdbc.
因为在表设计中有一个商品描述字段被设置为desc,但desc是mysql中的关键字,如select id,name,desc,price from product;这条sql语句在查询时的sql语句解析会和期望的不一样,导致出现问题。因为平时在写java代码的时候很自然的会将描述变量设置为desc,在设计表字段时也没有多想,忘记和忽略了desc为mysql中的关键字,酿成此问题。
翎野君
2023/05/12
7320
都说了能不动就别动,非要去调整,出生产事故了吧
  一个老项目,数据库用的是 MySQL 5.7.36 , ORM 框架用的 MyBatis 3.5.0 , mysql-connector-java 版本是 5.1.26
青石路
2024/02/24
1960
都说了能不动就别动,非要去调整,出生产事故了吧
java.sql.SQLException: connection holder is null
java.sql.SQLException: connection holder is null
一个会写诗的程序员
2018/08/17
2.2K0
性能调优之mysql线程池优化
对Nginx域名转发做了个压测,结果不大理想,jmeter哗哗的报错,nginx连接全是超时,tps波动特别大。如下图
飞天小子
2021/09/26
1.7K0
性能调优之mysql线程池优化
Cause: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x8E\xB1' for
最近在做关于社交项目时,有一个发红包功能,其中涉及到红包描述,一直报错,后来看日志,才发现竟是因为输入了Emoji表情的原因,由于我的mysql数据库是utf8字符集,而且Emoji表情等特殊符号要占四个字节,所以导致数据库不能正常存入。
一诺千金
2020/04/30
1.6K0
springcloud踩坑
直到我看见了 服务提供方的报错 一下子我就明白了 我数据库服务没开!!!!!!!!!!! 这里只是想分享以下踩坑经验 希望大家不要像我一样粗心
暴躁的程序猿
2022/03/24
3830
ShardingSphere分库分表schema名称导致NPE问题排查记录
前段时间把 ShardingSphere 升级到了 5.1.1 版本,奈何官方版本升级太快跟不上速度,这不最近又发现了一个 BUG。
艾小仙
2023/02/24
9870
ShardingSphere分库分表schema名称导致NPE问题排查记录
springboot整合mybatis报错
运行测试时报错如下 CLIENT_PLUGIN_AUTH is required
暴躁的程序猿
2022/03/23
3430
面试官:用SQL写一个死锁的案例
粉丝表示对Java中的死锁还是略知一二的,但是突然用SQL写死锁的案例之前还真没遇到过,这个问题没答上来。所以今天就带大家一起来看下怎么用SQL让数据库中产生死锁。
编程大道
2022/05/17
1.6K0
面试官:用SQL写一个死锁的案例
In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'c
数据库查询时,出现如下错误: Caused by: com.mysql.jdbc.exceptions.jdbc4MySQLSyntaxErrorException: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'credit_server.credit.id'; this is incompatible with sql_mode=only_full_gro
IT云清
2019/03/19
17.7K2
In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'c
springboot2.0配置多数据源出错HikariPool-1 - jdbcUrl is required with driverClassName.
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
suveng
2019/09/18
3.5K0
解决报错:Could not set property 'id' of 'class com.north.domain.Book' with value '1787299433834786818' C
捞月亮的小北
2024/05/07
5550
解决报错:Could not set property 'id' of 'class com.north.domain.Book' with value '1787299433834786818' C
BadSqlGrammarException:PageHelper use near 'LIMIT 50'
作为一名Java开发人员,你可能在某个深夜,面对着那令人头秃的错误日志,不禁发问:“为什么我的SQL语句总是出错?”今天,就让我们一起深入探讨这个在Java开发项目中常见的问题——org.springframework.jdbc.BadSqlGrammarException,特别是在处理Excel导入时,如何避免这个让人头疼的错误。
疯狂的KK
2025/01/16
2360
BadSqlGrammarException:PageHelper use near 'LIMIT 50'
In aggregated query without GROUP BY...this is incompatible with sql_mode=only_full_group_by
这种修改,不持久化,重启数据库后会再次出现此问题,所以,我们需要将此设置持久化到配置文件中。 首先找到mysql的配置文件,不同安装方式,配置文件位置或者名字不一样,我这里是my.cnf,未修改前内容如下:
IT云清
2022/05/07
1.2K0
In aggregated query without GROUP BY...this is incompatible with sql_mode=only_full_group_by
java.sql.SQLException: sql injection violation, multi-statement not allow
3、原因 需要设置过滤器 WallFilter 的配置: WallConfig 的参数 multiStatementAllow 为true,默认情况下false不允许批量操作
知识浅谈
2021/05/10
4.8K0
推荐阅读
都说了能不动就别动,非要去调整,出生产事故了吧 → 补充
2820
MysqlDataTruncation: Data truncation: Incorrect string value: '\xF0\x9D\x90\xB6"#...' for column
3K0
公司新来一个干练小伙,把 MyBatis 替换成 MyBatis-Plus,上线后哭晕在厕所。。。
2770
HTTP Status 500 - Request processing failed; nested exception is org.springframework.jdbc.BadSqlGram
6.3K0
HikariPool-1 - Exception during pool initialization. Springboot 默认选择的mysql问题
2790
一次org.springframework.jdbc.BadSqlGrammarException ### Error querying database Cause: com.mysql.jdbc.
7320
都说了能不动就别动,非要去调整,出生产事故了吧
1960
java.sql.SQLException: connection holder is null
2.2K0
性能调优之mysql线程池优化
1.7K0
Cause: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x8E\xB1' for
1.6K0
springcloud踩坑
3830
ShardingSphere分库分表schema名称导致NPE问题排查记录
9870
springboot整合mybatis报错
3430
面试官:用SQL写一个死锁的案例
1.6K0
In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'c
17.7K2
springboot2.0配置多数据源出错HikariPool-1 - jdbcUrl is required with driverClassName.
3.5K0
解决报错:Could not set property 'id' of 'class com.north.domain.Book' with value '1787299433834786818' C
5550
BadSqlGrammarException:PageHelper use near 'LIMIT 50'
2360
In aggregated query without GROUP BY...this is incompatible with sql_mode=only_full_group_by
1.2K0
java.sql.SQLException: sql injection violation, multi-statement not allow
4.8K0
相关推荐
都说了能不动就别动,非要去调整,出生产事故了吧 → 补充
更多 >
LV.0
这个人很懒,什么都没有留下~
交个朋友
加入前端学习入门群
前端基础系统教学 经验分享避坑指南
加入腾讯云技术交流站
前端技术前沿探索 云开发实战案例分享
加入云开发企业交流群
企业云开发实战交流 探讨技术架构优化
换一批
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档