Solved

JDBC problem

Posted on 2001-06-19
4
169 Views
Last Modified: 2010-03-31
hi ,
 suppose i have 5 tables ...say: A , B , C ,D , E.
i wanna read from table A and B and update C. Then i have to read from C and D and insert in to E. and if there is exception i wanna rollback the entire process. Now is it possible to insert in to table C and read from it again without commiting it ? . i mean can i read from table C if i have not commited the data in table C. i need to clarify that i am using the SAME Connection object for getting the Statement object.
  Also can you suggest me the best way of designing this in multithreaded environment >

Thanks
0
Comment
Question by:pravin_tiwari
4 Comments
 
LVL 2

Expert Comment

by:netuser1976
Comment Utility
Yes you can. You need to put all these transactions in the same transaction scope.
Thanks
Greg
0
 

Author Comment

by:pravin_tiwari
Comment Utility
hi,
  how does a transaction scope come in to picture if i m using te same COnnection object ... i mean everything i do before commit will by default wil come in same transaction ..isn't it ?

 Thanks
0
 
LVL 3

Accepted Solution

by:
superschlonz earned 10 total points
Comment Utility
Yes, that's right. Every statement you execute on the same connection
after a commit or rollback and before the next commit or rollback is in
the same transaction.
Don't forget to turn off autocommit !

And everything you change in a transaction can you read again in the
same transaction but not from other transactions until you made a
commit (which terminates the transaction and begins a new one).
0
 

Expert Comment

by:Nachiap
Comment Utility
auto commit off is default,this is simple you dont want to do anything,just put all your operations in single transaction.
and in oracle till you close the connection that is considered as a single transaction.

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
return in catch statement 1 39
firstChar challenge 13 82
mockito example issue 8 26
Java Jpanels and Jframe 8 19
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now