Reproduce com.mysql.jdbc.exceptions.jdbc4.CommunicationsException with a setup of Spring, hibernate and C3P0

后端 未结 3 963
独厮守ぢ
独厮守ぢ 2020-12-31 07:31

I got this error from the production code:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server

3条回答
  •  攒了一身酷
    2020-12-31 07:49

    To reproduce your error, set your connection timeout in your MySQL properties to a very low value, ie 2 ms, and run a query known to have a long processing time. You can set the timeout property either in the MySQL connection string or via a property if you're using properties files to setup your JDBC connection. You can look up the Javadocs on your specific jaxax.sql.DataSource connection and the MySQL docs for the specifics on how to do this.

提交回复
热议问题