I am creating a Java SE application having a MySQL database. It utilizes a connection pool of size 10 as you will find many screens. Each screen includes a Thread which will update some JTables about every ten seconds. My connection pooling code is obtained from http://java.sun.com/developer/onlineTraining/Programming/JDCBook/conpool.html having a couple of techniques added for my very own convenience.

My issue is that after I edit a few of the data within the application, and save it to the database, the JTables will at random display either the brand new up-to-date data, or even the old original data, every time the Thread runs to update the screen. It flickers backwards and forwards between new and old, every time the thread loops around.

I additionally possess some objects which i load by hitting a row within the JTable, and exhibiting their particulars in textBoxes. Basically click a row with data that's getting the issue above, the item that is loaded, also shows exactly the same "old" values. (This really is regardless of the object getting got a brand new, different connection in the database pool to load its values)

Once the JTable refreshes again, and shows the right "up-to-date" data - and that i load the item, the item also shows the right data.

Is an issue with the database connection pooling library i am using, it is possible to better alternative? I have attempted running my refreshing code with SQL_NO_CACHE but it has no effect. I am new here so tell me if there's anything i am missing in the particulars, thanks!

Attempt to alter the isolation level in your connections:

connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);

Also, make certain you handle your transactions properly, otherwise you may have random issues with phantom reads!

Edit: To be able to possess a correct isolation involving the connections, you have to disable auto-commit and surround write procedures in the transaction. If you don't do this a read from another connection might occur in the center of a write also it might return sporadic data.