当前位置:网站首页>Mysql client common exception analysis
Mysql client common exception analysis
2022-07-30 06:55:00 【If I don't see you tomorrow】
SocketTimeoutException
jdbc timeout包括Transaction Timeout/Statement Timeout/connectTimeout/socketTimeout四种类型,详细解释可见Jdbc & Mysql timeout分析
如果与服务器连接成功,The data transfer starts.如果服务器处理数据用时过长,超过了socketTimeout,就会抛出SocketTimeOutExceptin,即服务器响应超时
建议在jdbc url param中显示配置connectTimeout/socketTimeout,有效控制MySQL处理时间,并释放连接
jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&connectTimeout=3000&socketTimeout=5000
CommunicationsException
若发生 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 异常,Failed to connect to the database,But there can be multiple reasons for failure,roughly the same mysql 各种 timeout 参数相关
EOFException
net_write_timeout 控制 mysql serverTimeout for writing data to the client.If the client establishes a connection,超过该时间MySQLData has not been written yet,则会抛出EOFException
java.io.EOFException: Can not read response from server. Expected to read 34328 bytes, read 433 bytes before connection was unexpectedly lost.
SocketException
jdbcConnection will be based on mysql wait_timeout 检测空闲连接.若在 wait_timeout 时间内,The connection is still idle,mysql serverThis link will be broken.
与
MySQL建立连接成功后,MySQL主动断开连接,The underlying exception isjava.net.SocketException: Software caused connection abort: recv failed
SocketTimeoutException
sql执行时间超过socketTimeout的配置,则会抛出java.net.SocketTimeoutException: Read timed out
RecoverableDataAccessException
Disconnected is usedMySQL连接,会抛出org.springframework.dao.RecoverableDataAccessException
附表(MySQL timeout参数)
SHOW VARIABLES LIKE '%timeout%';可查看MySQL timeout参数
| 参数 | 描述 | 功能 |
|---|---|---|
| connect_timeout | 连接响应超时时间 | 服务器端在这个时间内如未连接成功,则会返回连接失败. |
| wait_timeout | 连接空闲超时时间 | 与服务器端无交互状态的连接,直到被服务器端强制关闭而等待的时间.It can be considered as the idle time of the server-side connection,If idle for more than this time, it will automatically shut down |
| interactive_timeout | 连接空闲超时时间 | 与服务器端无交互状态的连接,直到被服务器端强制关闭而等待的时间. |
| net_read_timeout | 数据读取超时时间 | before terminating the read,The number of seconds to wait to get data from a connection;When the service is reading data from the client,net_read_timeoutControls when to time out.That is, the client performs data reading,How many seconds to wait for automatic disconnection if still unsuccessful. |
| net_write_timeout | 数据库写超时时间 | 和net_read_timeout意义类似,before terminating the write,How many seconds to waitblockWrite to the connection;When the service is writing data to the client,net_write_timeoutControls when to time out. |
| slave-net-timeout | The time to delay synchronization from the library | 当slavethink connectedmasterwhen there is a problem with the connection,就等待N秒,然后断开连接,重新连接master |
interactive_timeout和wait_timeoutThe meaning is the same though,But there are essential differences in using objects.interactive_timeout针对交互式连接(比如通过mysql客户端连接数据库),wait_timeout针对非交互式连接(Like generallyPHP中使用PDO连接数据库,当然你可以设置CLIENT_INTERACTIVE选项来改变).所谓的交互式连接,即在mysql_real_connect()函数中使用了CLIENT_INTERACTIVE选项.
slave-net-timeoutWorks on slave libraries when master-slave is synchronized;connect_timeout:在获取连接阶段起作用;interactive_timeout和wait_timeout:Works during connection idle phase;net_read_timeout和net_write_timeout:It works when the connection is executed.
参考文档:
边栏推荐
猜你喜欢

FastAPI Quick Start

Servlet基本原理与常见API方法的应用

Connect to Mysql in the cloud server Docker detailed graphic and text operations (full)

MySQL - 多表查询与案例详解

Function 函数式接口及应用

Defense Ideas for a Type of SMS Vulnerability

Flink CDC 实现Postgres到MySQL流式加工传输案例

TDengine cluster construction

在线sql编辑查询工具sql-editor

【小程序项目开发-- 京东商城】uni-app之分类导航区域
随机推荐
MySQL - 多表查询与案例详解
MySQL achievement method 】 【 5 words, single table SQL queries
MySQL window function
MySQL 索引的数据结构及类型
[Ten years of network security engineers finishing] - 100 penetration testing tools introduction
Remember a Mailpress plugin RCE vulnerability recurrence
Using custom annotations, statistical method execution time
GraphQL(一)基础介绍及应用示例
2022CISCNmisc
MySQL 5.7 installation tutorial (all steps, nanny tutorials)
C#中使用OleDb操作access数据库
MySQL开窗函数
Detailed introduction to the usage of Nacos configuration center
TDengine cluster construction
Usage of exists in sql
Obtain geographic location and coordinates according to ip address (offline method)
The operations engineer interview experience
Thread state of five
Powerhouse Cup Preliminary WP
[Mozhe Academy] Identity Authentication Failure Vulnerability Actual Combat