Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connection and Commit problems between Oracle and Java

 
naveen banoor
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two questions.
1. Suppose an user modifies something on the screen and presses SAVE button and the back end (oracle) commits the data. Oracle passes the message to Java that the data is committed.
Just before the java receives this info ... say we lost connection between Oracle and Java (Session between Java and Oracle is closed).
Now the user doesn't know that the data is saved unless he/she requires.
I heard that Java takes care of the commit.
I don't know what exactly that means.
Does that mean we don't need to issue the COMMIT in PL/SQL program.

How is this situation handled in Java?

2. If multiple users are accessing the same record. User 1 and User 2 are having the same record queried to their screen. Both have update privs.
User1 updated the record and saved the data. User 2 doesn't know about this unless he refreshes the screen. He is going to change the same record and update it (which is wrong because he is updating old record).
we may take care of this by passing a message to the user when he/she presses the updated button that the record is changed...

Is this handled differently in java?
Thanks
Naveena
 
Anurag Gupta
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) If you are using a jdbc connection object in an AUTOCOMMIT=TRUE mode, then u dont need to issue the COMMIT explictly. However if the jdbc connection object is in an AUTOCOMMIT=FALSE Mode, then you need to explicitly commit the connection in order for the change to take place.
java.sql.Connection setAutoCommit(boolean autoCommit)
2) This condition is perfectly valid. The application design should take care of such situations.
You could use a select for update query, which would lock the record, so that none can modify it.(However this approach could have a repercussion of a Record becoming Locked, if the user does not proceed after the select.)
 
naveen banoor
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Anurag.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic