0 Replies Latest reply on Oct 8, 2004 12:13 PM by jrobette

    Problem with reading data from db while not already commited

    jrobette

      Hi,

      I'm not sure the title of this question is really clear. So I explain:

      I've a Postgresql DB configured this way :

      <datasources>
       <local-tx-datasource>
       <jndi-name>xxxDS</jndi-name>
       <connection-url>jdbc:postgresql://xxx:5432/xxx</connection-url>
       <driver-class>org.postgresql.Driver</driver-class>
       <user-name>xxx</user-name>
       <password>xxx</password>
       </local-tx-datasource>
      </datasources>
      


      In my application, I do the following :

      1 : get a connection from datasource (xxxDS)
      2 : insert some data in the database
      3 : put a message in a queue
      4 : release the connection

      Then another application do the following :

      5 : get the message from the queue (MDB)
      6 : get a connection from datasource (xxxDS)
      7 : call a stored procedure in the database
      8 : get the results
      9 : release the connection
      10 : etc...


      My problem is that I get an error 50% of the time.
      It is due to :
      the stored procedure does not find the data which should have just been inserted.

      So, I conclude that it is a problem of transaction. The first connection has not yet commited while the second is already performing.

      Am I right with this conclusion?
      What should I do then to get it work?
      Maybe, I should force the commit but how (commit() is forbidden : "You cannot commit during a managed transaction!")?

      Thanks a lot!

      JR