当前位置:网站首页>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 server
Timeout 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
jdbc
Connection will be based on mysql wait_timeout
检测空闲连接.若在 wait_timeout
时间内,The connection is still idle,mysql server
This 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_timeout
The 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-timeout
Works 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.
参考文档:
边栏推荐
- The operations engineer interview experience
- Offensive and defensive world easy_web
- SQL Server database generation and execution of SQL scripts
- Jackson 序列化失败问题-oracle数据返回类型找不到对应的Serializer
- uni-app: about custom components, easycom specs, uni_modules, etc.
- Understand JDBC in one article
- 【SQL】first_value 应用场景 - 首单 or 复购
- 【SQL】SQL 高频面试题英语版(1)
- kali is an essential artifact for information security
- uncategorized SQLException; SQL state [null]; error code [0]; sql injection violation, syntax error
猜你喜欢
JDBC programming of MySQL database
CTFSHOW command execution [web29-web124] unfinished to be continued
awd --waf deployment
misc-file steganography of CTF
MySQL数据库之JDBC编程
正则表达式语法详解及实用实例
phpok website vulnerability exploitation analysis
Flink CDC implements Postgres to MySQL streaming processing transmission case
php-fpm
Flink CDC 实现Postgres到MySQL流式加工传输案例
随机推荐
Using custom annotations, statistical method execution time
使用PyQt5为YoloV5添加界面(一)
The operations engineer interview experience
shardingsphere 分库分表及配置示例
Communication middleware Fast DDS basic concepts and communication examples
C#利用开源NPlot实现K线图(蜡烛图)
【零基础搞定C语言——导航汇总篇】
misc-file steganography of CTF
CTFSHOW command execution [web29-web124] unfinished to be continued
【Spark】Spark 高频面试题英语版(1)
Servlet基本原理与常见API方法的应用
Remember a Mailpress plugin RCE vulnerability recurrence
oracle行转列、列转行总结
C#中对委托的理解和使用
c#下Web3合约空投、转账调用代码
JVM学习(二) 垃圾收集器
TDengine cluster construction
TDengine集群搭建
Flink PostgreSQL CDC configuration and FAQ
Flink PostgreSQL CDC配置和常见问题