This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Myself Ankit. I am using java & oracle 10g. Rightnow I am creating connection. Use it to insert data into tables.
But I want to make my program such that i can commit the insertion only at one time.
Suppose I have three webforms in child pages i am inserting some data into tables, but i m not committing in these two pages. But i m committing at master pages that is parent page to commit.
Now My question is that can i maitain only one connection throught the session. Like in oracle when we login, and do any operation it will visible through my session & not visible for the others until commit will be executed from my session. I want to perform this functionality through java.
Can anybody have any idea regarding this??? Please reply me as soon as possible......
You can, by saving the connection as a session object. In that case, however, you had better have a session listener to close these connections (and do a rollback to make be certain that by a timedout session nothing remains locked) or you will soon use up all your connections with dangling cursors. This may happen anyway, if you have a long timeout and a alot of users. That is one of the reasons why this should never be done.
You should not attempt to link sessions to connections as you are proposing; instead you need to collect the data on the different pages, store it in session variables, and use one transaction initiated by the final page to put it in the database.
Connections are very very expensive things to have open and not in use; in a web application, an open connection should either be being actively used, or in a connection pool waiting to be used, and nowhere else.