mysql Communications link failure

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during rollback().看到这个错误后先查看代码,首先想到
<iframe id="cproIframe_u2330612_3" style="margin: 0px; padding: 0px;" src="http://pos.baidu.com/acom?adn=3&amp;adp=1&amp;at=0&amp;aurl=&amp;c01=1&amp;cad=1&amp;ccd=24&amp;cec=GBK&amp;cfv=0&amp;ch=0&amp;col=zh-CN&amp;conBW=1&amp;conOP=1&amp;cpa=1&amp;cpro_lu=1%2C%23dfe4f9%2C%23000000%2C%E5%AE%8B%E4%BD%93&amp;dai=3&amp;dis=0&amp;layout_filter=image&amp;ltr=https%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3DkE-PAM6G9mNftETqRRx83baKiUWxI6RdwUYY3Zn6HPSxlVHC___jx3H9nStzXCiVqfHY4Jfwl0Hm6wloul9KE591fEp8IBZNr3n4fFogSam%26wd%3D%26eqid%3D9d83345600047ae900000002566ba9c7&amp;ltu=http%3A%2F%2Fwww.68idc.cn%2Fhelp%2Fbuildlang%2Fask%2F20150616370237.html&amp;lu_161=0&amp;lunum=6&amp;n=24066120_cpr&amp;pat=17&amp;pcs=1754x736&amp;pis=10000x10000&amp;ps=549x394&amp;psr=1920x1080&amp;pss=1754x575&amp;ptt=0&amp;qn=4d3e8821fb27d2a5&amp;rad=&amp;rsi0=300&amp;rsi1=300&amp;rsi5=4&amp;rss0=%23FFFFFF&amp;rss1=%23FFFFFF&amp;rss2=%23000000&amp;rss3=%23444444&amp;rss4=%23008000&amp;rss5=&amp;rss6=%23e10900&amp;rss7=&amp;scale=&amp;skin=tabcloud_skin_5&amp;stid=5&amp;td_id=2330612&amp;titFF=%E5%AE%8B%E4%BD%93&amp;titFS=14&amp;titSU=0&amp;titTA=left&amp;tn=baiduCustNativeAD&amp;tpr=1449898471080&amp;ts=1&amp;version=2.0&amp;xuanting=0&amp;dtm=BAIDU_DUP2_SETJSONADSLOT&amp;dc=2&amp;di=u2330612&amp;ti=mysql%20Communications%20link%20failure%20(with%20http%20request)%20-%20%E9%B8%BF%E7%BD%91%E4%BA%92%E8%81%94&amp;tt=1449898471068.615.889.889" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" align="center,center" width="300" height="300"></iframe>
<iframe id="cproIframe_u2330621_4" style="margin: 0px; padding: 0px;" src="http://pos.baidu.com/acom?adn=0&amp;at=128&amp;aurl=&amp;cad=1&amp;ccd=24&amp;cec=GBK&amp;cfv=0&amp;ch=0&amp;col=zh-CN&amp;conBW=0&amp;conOP=1&amp;cpa=1&amp;cpro_lu=1%2C%23dfe4f9%2C%23000000%2C%E5%AE%8B%E4%BD%93&amp;dai=4&amp;dis=0&amp;ltr=https%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3DkE-PAM6G9mNftETqRRx83baKiUWxI6RdwUYY3Zn6HPSxlVHC___jx3H9nStzXCiVqfHY4Jfwl0Hm6wloul9KE591fEp8IBZNr3n4fFogSam%26wd%3D%26eqid%3D9d83345600047ae900000002566ba9c7&amp;ltu=http%3A%2F%2Fwww.68idc.cn%2Fhelp%2Fbuildlang%2Fask%2F20150616370237.html&amp;lu_161=0&amp;lunum=6&amp;n=24066120_cpr&amp;pcs=1754x736&amp;pis=10000x10000&amp;ps=549x1034&amp;psr=1920x1080&amp;pss=1754x875&amp;qn=dd115ff2fd3f605d&amp;rad=&amp;rsi0=300&amp;rsi1=300&amp;rsi5=4&amp;rss0=%2386AC5F&amp;rss1=%23FFFFFF&amp;rss2=%230000ff&amp;rss3=&amp;rss4=&amp;rss5=&amp;rss6=%23e10900&amp;rss7=&amp;scale=&amp;skin=tabcloud_skin_5&amp;stid=5&amp;td_id=2330621&amp;titFF=%E5%AE%8B%E4%BD%93&amp;titFS=12&amp;titTA=left&amp;tn=baiduCustSTagLinkUnit&amp;tpr=1449898471080&amp;ts=1&amp;version=2.0&amp;xuanting=0&amp;dtm=BAIDU_DUP2_SETJSONADSLOT&amp;dc=2&amp;di=u2330621&amp;ti=mysql%20Communications%20link%20failure%20(with%20http%20request)%20-%20%E9%B8%BF%E7%BD%91%E4%BA%92%E8%81%94&amp;tt=1449898471068.897.1057.1057" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" align="center,center" width="300" height="300"></iframe>

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during rollback().看到这个错误后先查看代码,首先想到,我先打开的数据库连接,并且执行了query和insert操作都没问题啊,但是最后的回滚就出问题了,下面根据日志分析一下:

mysql Communications link failure (with http request)

 

mysql Communications link failure (with http request)

 

 

 

mysql Communications link failure (with http request)

 

解决方案:
1. 修改Http请求时间,,连接请求超时+读取超时<60ms
2. 不要将HTTP请求放到数据库的事务操作中:
1) 在HTTP请求前执行完数据库操作,再执行HTTP请求,在更新之前操作的状态(成功、失败、未知)
2) 数据库的记录允许一定的丢数据,先执行HTTP请求,然后将执行结果在写入数据库

 

http://www.68idc.cn/help/buildlang/ask/20150616370237.html

猜你喜欢

转载自m635674608.iteye.com/blog/2263613