This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JDBC and the fly likes Regarding JDBC Connection (URGENT) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Regarding JDBC Connection (URGENT)" Watch "Regarding JDBC Connection (URGENT)" New topic
Author

Regarding JDBC Connection (URGENT)

Ankit Thakkar
Ranch Hand

Joined: Apr 29, 2005
Posts: 33

Hi Friends,

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......


- Ankit
Martin Simons
Ranch Hand

Joined: Mar 02, 2006
Posts: 196
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.
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding JDBC Connection (URGENT)