当前位置:网站首页>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.
参考文档:
边栏推荐
- 互联网商城盲盒app为何如此火爆
- MySQL存储引擎
- Awd summary
- Operators and Interaction Basics
- Solution to TypeError The view function did not return a valid response. The function either returned None
- Monstache执行Monstache - f配置。toml出错不存在处理器类型和名称(附件)(= parse_exc类型
- Offensive and defensive world easy_web
- FastAPI Quick Start
- awd --waf deployment
- oracle row to column, column to row summary
猜你喜欢

mysql不是内部或外部命令,也不是可运行的程序或批处理文件解决

JVM学习(二) 垃圾收集器

mysql删除表中重复数据,(只保留一行)

npm run serve starts error npm ERR Missing script "serve"

MySQL开窗函数
![CTFSHOW command execution [web29-web124] unfinished to be continued](/img/89/786fbe65af4c9f269530bf2d08e1a0.png)
CTFSHOW command execution [web29-web124] unfinished to be continued

MySQL数据库之JDBC编程

Flink CDC implements Postgres to MySQL streaming processing transmission case

SSTI range

Redis 发布/订阅
随机推荐
TDengineGUI cannot connect to TDengine
Misc of CTF-image steganography
FastAPI Quick Start
Online sql editing query tool sql-editor
Servlet basic principles and application of common API methods
使用PyQt5为YoloV5添加界面(一)
sqli-labs shooting range SQL injection learning Less-1
利用自定义注解,统计方法执行时间
uncategorized SQLException; SQL state [null]; error code [0]; sql injection violation, syntax error
Arthas 命令解析(watch/tt/sc)
C#中对委托的理解和使用
Dcat Admin installation
mysql删除表中重复数据,(只保留一行)
TypeError The view function did not return a valid response. The function either returned None 的解决
Misc of CTF - other types of steganography
MySQL 数据类型及占用空间
Understand JDBC in one article
The operations engineer interview experience
kali is an essential artifact for information security
POI工具类