wood burning stoves 2.0*
The moose likes JDBC and the fly likes Connection and Commit problems between Oracle and Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connection and Commit problems between Oracle and Java" Watch "Connection and Commit problems between Oracle and Java" New topic
Author

Connection and Commit problems between Oracle and Java

naveen banoor
Greenhorn

Joined: Dec 11, 2003
Posts: 2
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

Joined: Dec 13, 2001
Posts: 40
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.)


Anurag Gupta
naveen banoor
Greenhorn

Joined: Dec 11, 2003
Posts: 2
Thank You Anurag.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connection and Commit problems between Oracle and Java
 
Similar Threads
How to achive Optimistic Locking for an Application
pls validate my locking strategy - all inputs are g8ly appreciated. (URLyBird)
Caching Problems with borwsers.
Lost Update/Concurrency issues in web application
About the opporunity of calling lock method