Java database error : java.sql.SQLException: Io exception: Bad packet type

I randomly got this error

java.sql.SQLException: Io exception: Bad packet type

I did some research, someone suggested a solution:

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.

Can anyone guide me in how to ensure that only one thread of execution was making use of the JDBC driver at a time ?

Answers


We resolved the problem by closing the connection of a preparedStatement, instead of the Database connection itself.

Use:

ps.getConnection().close();

instead of :

conn.close();

Need Your Help

Changing constraints on the fly

dojo dijit.form

I have a dijit.form.NumberTextBox input field that starts out with these parms:

Duplicate a collection of entities and persist in Hibernate/JPA

java hibernate orm collections jpa

I want to duplicate a collection of entities in my database.