This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Connection has cached information? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Connection has cached information?" Watch "Connection has cached information?" New topic

Connection has cached information?

Andreas Bystrom
Ranch Hand

Joined: Mar 05, 2003
Posts: 32
I have a problem with my Java connections to a mySQL database.
In my scenario I have a connection pool, and the behavior is different depending on the size of this pool.
Scenario 1:
I have 2 connections in the pool (c1 and c2). The table I'm about to read has 2 records. I use c1 to read and get two records. I then use c2 to add another record (this works, if I look in the database, the new record is there). I commit the changes. I then use c1 to read the same table but still gets only to records (the same two as before).
Scenario 2:
I have 3 connections (c1, c2 and c3). The table again has two records. I use c1 to read and get this two records. I then use c2 o add a new record and commit the changes. Then I use c3 to read the same table and now I get 3 records (the to "old" and the newly added).
My question is if there can be some kind of chache in the connections? Have someone come across this behavior before? The connections TransactionIsolation is set to TRANSACTION_READ_COMITTED.
Thanks in advance,
subject: Connection has cached information?