Closed FelixVincent99 closed 4 years ago
You may lose the connection to a MySQL server due to network problems, the server timing you out, the server being restarted, or crashing. All of these events are considered fatal errors, and will have the err.code = 'PROTOCOL_CONNECTION_LOST'. See the Error Handling section for more information.
Re-connecting a connection is done by establishing a new connection. Once terminated, an existing connection object cannot be re-connected by design.
Using a connection object after a fatal error will result in the error that you are experiencing. You should not try to manually reconnect a connection object that has been disconnected or resulted in a fatal error.
I suggest that you use pooling instead of a single connection. Specifically because:
With Pool, disconnected connections will be removed from the pool freeing up space for a new connection to be created on the next getConnection call.
See Server disconnects and Pooling connections for more information.
Can someone help me with this: