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&adp=1&at=0&aurl=&c01=1&cad=1&ccd=24&cec=GBK&cfv=0&ch=0&col=zh-CN&conBW=1&conOP=1&cpa=1&cpro_lu=1%2C%23dfe4f9%2C%23000000%2C%E5%AE%8B%E4%BD%93&dai=3&dis=0&layout_filter=image&ltr=https%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3DkE-PAM6G9mNftETqRRx83baKiUWxI6RdwUYY3Zn6HPSxlVHC___jx3H9nStzXCiVqfHY4Jfwl0Hm6wloul9KE591fEp8IBZNr3n4fFogSam%26wd%3D%26eqid%3D9d83345600047ae900000002566ba9c7&ltu=http%3A%2F%2Fwww.68idc.cn%2Fhelp%2Fbuildlang%2Fask%2F20150616370237.html&lu_161=0&lunum=6&n=24066120_cpr&pat=17&pcs=1754x736&pis=10000x10000&ps=549x394&psr=1920x1080&pss=1754x575&ptt=0&qn=4d3e8821fb27d2a5&rad=&rsi0=300&rsi1=300&rsi5=4&rss0=%23FFFFFF&rss1=%23FFFFFF&rss2=%23000000&rss3=%23444444&rss4=%23008000&rss5=&rss6=%23e10900&rss7=&scale=&skin=tabcloud_skin_5&stid=5&td_id=2330612&titFF=%E5%AE%8B%E4%BD%93&titFS=14&titSU=0&titTA=left&tn=baiduCustNativeAD&tpr=1449898471080&ts=1&version=2.0&xuanting=0&dtm=BAIDU_DUP2_SETJSONADSLOT&dc=2&di=u2330612&ti=mysql%20Communications%20link%20failure%20(with%20http%20request)%20-%20%E9%B8%BF%E7%BD%91%E4%BA%92%E8%81%94&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&at=128&aurl=&cad=1&ccd=24&cec=GBK&cfv=0&ch=0&col=zh-CN&conBW=0&conOP=1&cpa=1&cpro_lu=1%2C%23dfe4f9%2C%23000000%2C%E5%AE%8B%E4%BD%93&dai=4&dis=0&ltr=https%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3DkE-PAM6G9mNftETqRRx83baKiUWxI6RdwUYY3Zn6HPSxlVHC___jx3H9nStzXCiVqfHY4Jfwl0Hm6wloul9KE591fEp8IBZNr3n4fFogSam%26wd%3D%26eqid%3D9d83345600047ae900000002566ba9c7&ltu=http%3A%2F%2Fwww.68idc.cn%2Fhelp%2Fbuildlang%2Fask%2F20150616370237.html&lu_161=0&lunum=6&n=24066120_cpr&pcs=1754x736&pis=10000x10000&ps=549x1034&psr=1920x1080&pss=1754x875&qn=dd115ff2fd3f605d&rad=&rsi0=300&rsi1=300&rsi5=4&rss0=%2386AC5F&rss1=%23FFFFFF&rss2=%230000ff&rss3=&rss4=&rss5=&rss6=%23e10900&rss7=&scale=&skin=tabcloud_skin_5&stid=5&td_id=2330621&titFF=%E5%AE%8B%E4%BD%93&titFS=12&titTA=left&tn=baiduCustSTagLinkUnit&tpr=1449898471080&ts=1&version=2.0&xuanting=0&dtm=BAIDU_DUP2_SETJSONADSLOT&dc=2&di=u2330621&ti=mysql%20Communications%20link%20failure%20(with%20http%20request)%20-%20%E9%B8%BF%E7%BD%91%E4%BA%92%E8%81%94&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操作都没问题啊,但是最后的回滚就出问题了,下面根据日志分析一下:
解决方案:
1. 修改Http请求时间,,连接请求超时+读取超时<60ms2. 不要将HTTP请求放到数据库的事务操作中:1) 在HTTP请求前执行完数据库操作,再执行HTTP请求,在更新之前操作的状态(成功、失败、未知)2) 数据库的记录允许一定的丢数据,先执行HTTP请求,然后将执行结果在写入数据库
http://www.68idc.cn/help/buildlang/ask/20150616370237.html