Java数据库错误:java.sql.SQLException:Io异常:错误的数据包类型 [英] Java database error : java.sql.SQLException: Io exception: Bad packet type
本文介绍了Java数据库错误:java.sql.SQLException:Io异常:错误的数据包类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我随机遇到此错误
java.sql.SQLException: Io exception: Bad packet type
我做了一些研究,有人提出了解决方案:
I did some research, someone suggested a solution:
要解决此问题,我们必须确保通过同一Connection或一次升级到更高版本的驱动程序,一次仅使用一个执行线程来使用JDBC驱动程序.
To correct this problem we have to ensure that only one thread of execution was making use of the JDBC driver at a time through the same Connection OR upgrade to a later version of the driver.
有人可以指导我如何确保一次只有一个执行线程在使用JDBC驱动程序吗?
Can anyone guide me in how to ensure that only one thread of execution was making use of the JDBC driver at a time ?
推荐答案
我们通过关闭prepareStatement的连接而不是数据库连接本身来解决该问题.
We resolved the problem by closing the connection of a preparedStatement, instead of the Database connection itself.
使用:
ps.getConnection().close();
而不是:
conn.close();
这篇关于Java数据库错误:java.sql.SQLException:Io异常:错误的数据包类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文