This topic lists the general problems and the corresponding troubleshooting methods.
Troubleshoot an error with the error message "Could not read resultset: unexpected end of stream, read 0 bytes from 4"
The error occurs during communication with the server.
In most cases, this is caused by queries with a large number of result sets. A server usually expects the client to rapidly read the result set. net_write_timeout specifies the read timeout period. The default value is 60s. If the client fails to read the entire result set during this period, the server discards the connection. If you do not want to process the results in the specified period, you can run SET STATEMENT net_write_timeout = 10000 FOR XXX, where XXX indicates a "general" query. In this case, set net_write_timeout to a larger value for the query, which is 10000 in this example.
If the application uses many long queries configured with FetchSize, you can use the sessionVariables = net_write_timeout = xxx option to set the connection.
Perform lightweight ping/ operations to avoid excessive use of "SELECT 1"
You can use Connection.isValid() to perform lightweight ping/ operations to avoid excessive use of SELECT 1. Connection.isValid() implements ping operations in MySQL protocols, rather than on the network.