title: Mysql read data immediately after writing?
body: <p>I am using a MySQL DB and a Java JDBC client to access it. </p>
  
  <p>I have a Table that contains session information. Each session is associated with a SessionToken. This token is a Base64 encoded String of a Hash of some of the session values. It should be unique. And is defined as varchar(50) in the db. </p>
  
  <p>When I try to lookup a session by its token I query the database using an sql statement like this: </p>
  
  <pre><code>select SessionId, ClientIP, PersonId, LastAccessTime, SessionCreateTime from InkaSession where SessionToken like 'exK/Xw0imW/qOtN39uw5bddeeMg='
  </code></pre>
  
  <p>I have a UnitTest that tests this functionality, and it consistently fails, because the query does not return any Session, even tough, I have just written the session to the DB. </p>
  
  <p>My Unit test does the following: </p>
  
  <pre><code>Create Connection via DriverManager.getConnection
  Add a session via Sql Insert query
  close the connection
  
  create Connection via DriverManager.getConnection
  look for the session via sql select
  unit test fails, because nothing found
  </code></pre>
  
  <p>When I step through this UnitTest with the debugger and copy past the select sql that is about to be sent to the db into a mysql command line, it works fine, and I get the session row back. </p>
  
  <p>I also tried to retrive an older session from the db by asking for an older SessionToken. This works fine as well. It only fails, if I ask for the SessionToken immediately after I inserted it. </p>
  
  <p>All connections are on AutoCommit. Nevertheless I tried to set the Transaction Level to "Read Uncommited". This did not work either. </p>
  
  <p>Has anyone any further suggestions?</p>